author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Tue, 24 Feb 2015 11:12:53 +0100 | |
changeset 1787 | ea12a3bb4b33 |
parent 1474 | 3775fe162073 |
permissions | -rw-r--r-- |
jaroslav@1453 | 1 |
/** |
jaroslav@1453 | 2 |
* Back 2 Browser Bytecode Translator |
jaroslav@1787 | 3 |
* Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@1453 | 4 |
* |
jaroslav@1453 | 5 |
* This program is free software: you can redistribute it and/or modify |
jaroslav@1453 | 6 |
* it under the terms of the GNU General Public License as published by |
jaroslav@1453 | 7 |
* the Free Software Foundation, version 2 of the License. |
jaroslav@1453 | 8 |
* |
jaroslav@1453 | 9 |
* This program is distributed in the hope that it will be useful, |
jaroslav@1453 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jaroslav@1453 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jaroslav@1453 | 12 |
* GNU General Public License for more details. |
jaroslav@1453 | 13 |
* |
jaroslav@1453 | 14 |
* You should have received a copy of the GNU General Public License |
jaroslav@1453 | 15 |
* along with this program. Look for COPYING file in the top folder. |
jaroslav@1453 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
jaroslav@1453 | 17 |
*/ |
jaroslav@1453 | 18 |
package org.apidesign.vm4brwsr; |
jaroslav@1453 | 19 |
|
jaroslav@1457 | 20 |
import java.io.IOException; |
jaroslav@1457 | 21 |
import java.io.InputStream; |
jaroslav@1453 | 22 |
import static org.testng.Assert.assertEquals; |
jaroslav@1453 | 23 |
import org.testng.annotations.AfterClass; |
jaroslav@1453 | 24 |
import org.testng.annotations.BeforeClass; |
jaroslav@1453 | 25 |
import org.testng.annotations.Test; |
jaroslav@1453 | 26 |
|
jaroslav@1453 | 27 |
/** |
jaroslav@1453 | 28 |
* |
jaroslav@1453 | 29 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jaroslav@1453 | 30 |
*/ |
jaroslav@1474 | 31 |
public class NoStringCnstntsTest { |
jaroslav@1457 | 32 |
private static String code; |
jaroslav@1453 | 33 |
|
jaroslav@1453 | 34 |
|
jaroslav@1472 | 35 |
@Test public void dontGeneratePrimitiveFinalConstants() { |
jaroslav@1474 | 36 |
assertEquals(code.indexOf("HELLO"), -1, "MISSING_CONSTANT field should not be generated"); |
jaroslav@1472 | 37 |
} |
jaroslav@1453 | 38 |
|
jaroslav@1453 | 39 |
@BeforeClass |
jaroslav@1453 | 40 |
public static void compileTheCode() throws Exception { |
jaroslav@1474 | 41 |
final String res = "org/apidesign/vm4brwsr/StringSample"; |
jaroslav@1453 | 42 |
StringBuilder sb = new StringBuilder(); |
jaroslav@1457 | 43 |
class JustStaticMethod implements Bck2Brwsr.Resources { |
jaroslav@1457 | 44 |
@Override |
jaroslav@1457 | 45 |
public InputStream get(String resource) throws IOException { |
jaroslav@1457 | 46 |
final String cn = res + ".class"; |
jaroslav@1457 | 47 |
if (resource.equals(cn)) { |
jaroslav@1457 | 48 |
return getClass().getClassLoader().getResourceAsStream(cn); |
jaroslav@1457 | 49 |
} |
jaroslav@1457 | 50 |
return null; |
jaroslav@1457 | 51 |
} |
jaroslav@1457 | 52 |
} |
jaroslav@1457 | 53 |
Bck2Brwsr.generate(sb, new JustStaticMethod(), res); |
jaroslav@1457 | 54 |
code = sb.toString(); |
jaroslav@1453 | 55 |
} |
jaroslav@1453 | 56 |
@AfterClass |
jaroslav@1453 | 57 |
public static void releaseTheCode() { |
jaroslav@1453 | 58 |
code = null; |
jaroslav@1453 | 59 |
} |
jaroslav@1453 | 60 |
|
jaroslav@1453 | 61 |
} |