jtulach@169: /** jtulach@169: * Back 2 Browser Bytecode Translator jtulach@169: * Copyright (C) 2012 Jaroslav Tulach jtulach@169: * jtulach@169: * This program is free software: you can redistribute it and/or modify jtulach@169: * it under the terms of the GNU General Public License as published by jtulach@169: * the Free Software Foundation, version 2 of the License. jtulach@169: * jtulach@169: * This program is distributed in the hope that it will be useful, jtulach@169: * but WITHOUT ANY WARRANTY; without even the implied warranty of jtulach@169: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jtulach@169: * GNU General Public License for more details. jtulach@169: * jtulach@169: * You should have received a copy of the GNU General Public License jtulach@169: * along with this program. Look for COPYING file in the top folder. jtulach@169: * If not, see http://opensource.org/licenses/GPL-2.0. jtulach@169: */ jtulach@169: package org.apidesign.vm4brwsr; jtulach@169: jtulach@169: import static org.testng.Assert.*; jtulach@169: import javax.script.Invocable; jtulach@169: import org.testng.annotations.BeforeClass; jtulach@169: import org.testng.annotations.Test; jtulach@169: jtulach@169: /** jtulach@169: * jtulach@169: * @author Jaroslav Tulach jtulach@169: */ jtulach@169: public class VMinVMTest { jtulach@169: jtulach@169: private static CharSequence codeSeq; jtulach@169: private static Invocable code; jtulach@169: jtulach@169: @Test public void compareTheGeneratedCode() throws Exception { jtulach@169: StringBuilder hotspot = new StringBuilder(); jtulach@169: GenJS.compile(hotspot, "org/apidesign/vm4brwsr/Array"); jtulach@169: jtulach@169: Object ret = code.invokeFunction( jtulach@169: "org_apidesign_vm4brwsr_GenJS_toStringLjava_lang_StringLjava_lang_String", jtulach@169: "org/apidesign/vm4brwsr/Array" jtulach@169: ); jtulach@169: assertTrue(ret instanceof String, "It is string: " + ret); jtulach@169: jtulach@169: assertEquals((String)ret, hotspot.toString(), "The code is the same"); jtulach@169: } jtulach@169: jtulach@169: @BeforeClass jtulach@169: public void compileTheCode() throws Exception { jtulach@169: StringBuilder sb = new StringBuilder(); jtulach@169: code = StaticMethodTest.compileClass(sb, jtulach@169: "org/apidesign/vm4brwsr/GenJS" jtulach@169: ); jtulach@169: codeSeq = sb; jtulach@169: } jtulach@169: }