jaroslav@1453: /** jaroslav@1453: * Back 2 Browser Bytecode Translator jaroslav@1787: * Copyright (C) 2012-2015 Jaroslav Tulach jaroslav@1453: * jaroslav@1453: * This program is free software: you can redistribute it and/or modify jaroslav@1453: * it under the terms of the GNU General Public License as published by jaroslav@1453: * the Free Software Foundation, version 2 of the License. jaroslav@1453: * jaroslav@1453: * This program is distributed in the hope that it will be useful, jaroslav@1453: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1453: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1453: * GNU General Public License for more details. jaroslav@1453: * jaroslav@1453: * You should have received a copy of the GNU General Public License jaroslav@1453: * along with this program. Look for COPYING file in the top folder. jaroslav@1453: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1453: */ jaroslav@1453: package org.apidesign.vm4brwsr; jaroslav@1453: jaroslav@1457: import java.io.IOException; jaroslav@1457: import java.io.InputStream; jaroslav@1453: import static org.testng.Assert.assertEquals; jaroslav@1453: import org.testng.annotations.AfterClass; jaroslav@1453: import org.testng.annotations.BeforeClass; jaroslav@1453: import org.testng.annotations.Test; jaroslav@1453: jaroslav@1453: /** jaroslav@1453: * jaroslav@1453: * @author Jaroslav Tulach jaroslav@1453: */ jaroslav@1474: public class NoStringCnstntsTest { jaroslav@1457: private static String code; jaroslav@1453: jaroslav@1453: jaroslav@1472: @Test public void dontGeneratePrimitiveFinalConstants() { jaroslav@1474: assertEquals(code.indexOf("HELLO"), -1, "MISSING_CONSTANT field should not be generated"); jaroslav@1472: } jaroslav@1453: jaroslav@1453: @BeforeClass jaroslav@1453: public static void compileTheCode() throws Exception { jaroslav@1474: final String res = "org/apidesign/vm4brwsr/StringSample"; jaroslav@1453: StringBuilder sb = new StringBuilder(); jaroslav@1457: class JustStaticMethod implements Bck2Brwsr.Resources { jaroslav@1457: @Override jaroslav@1457: public InputStream get(String resource) throws IOException { jaroslav@1457: final String cn = res + ".class"; jaroslav@1457: if (resource.equals(cn)) { jaroslav@1457: return getClass().getClassLoader().getResourceAsStream(cn); jaroslav@1457: } jaroslav@1457: return null; jaroslav@1457: } jaroslav@1457: } jaroslav@1457: Bck2Brwsr.generate(sb, new JustStaticMethod(), res); jaroslav@1457: code = sb.toString(); jaroslav@1453: } jaroslav@1453: @AfterClass jaroslav@1453: public static void releaseTheCode() { jaroslav@1453: code = null; jaroslav@1453: } jaroslav@1453: jaroslav@1453: }