author | Jaroslav Tulach <jtulach@netbeans.org> |
Fri, 16 Nov 2012 08:26:55 +0100 | |
branch | javap |
changeset 169 | 6f2aef4cf160 |
child 170 | 2336c52d3ee5 |
permissions | -rw-r--r-- |
jtulach@169 | 1 |
/** |
jtulach@169 | 2 |
* Back 2 Browser Bytecode Translator |
jtulach@169 | 3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jtulach@169 | 4 |
* |
jtulach@169 | 5 |
* This program is free software: you can redistribute it and/or modify |
jtulach@169 | 6 |
* it under the terms of the GNU General Public License as published by |
jtulach@169 | 7 |
* the Free Software Foundation, version 2 of the License. |
jtulach@169 | 8 |
* |
jtulach@169 | 9 |
* This program is distributed in the hope that it will be useful, |
jtulach@169 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jtulach@169 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jtulach@169 | 12 |
* GNU General Public License for more details. |
jtulach@169 | 13 |
* |
jtulach@169 | 14 |
* You should have received a copy of the GNU General Public License |
jtulach@169 | 15 |
* along with this program. Look for COPYING file in the top folder. |
jtulach@169 | 16 |
* If not, see http://opensource.org/licenses/GPL-2.0. |
jtulach@169 | 17 |
*/ |
jtulach@169 | 18 |
package org.apidesign.vm4brwsr; |
jtulach@169 | 19 |
|
jtulach@169 | 20 |
import static org.testng.Assert.*; |
jtulach@169 | 21 |
import javax.script.Invocable; |
jtulach@169 | 22 |
import org.testng.annotations.BeforeClass; |
jtulach@169 | 23 |
import org.testng.annotations.Test; |
jtulach@169 | 24 |
|
jtulach@169 | 25 |
/** |
jtulach@169 | 26 |
* |
jtulach@169 | 27 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jtulach@169 | 28 |
*/ |
jtulach@169 | 29 |
public class VMinVMTest { |
jtulach@169 | 30 |
|
jtulach@169 | 31 |
private static CharSequence codeSeq; |
jtulach@169 | 32 |
private static Invocable code; |
jtulach@169 | 33 |
|
jtulach@169 | 34 |
@Test public void compareTheGeneratedCode() throws Exception { |
jtulach@169 | 35 |
StringBuilder hotspot = new StringBuilder(); |
jtulach@169 | 36 |
GenJS.compile(hotspot, "org/apidesign/vm4brwsr/Array"); |
jtulach@169 | 37 |
|
jtulach@169 | 38 |
Object ret = code.invokeFunction( |
jtulach@169 | 39 |
"org_apidesign_vm4brwsr_GenJS_toStringLjava_lang_StringLjava_lang_String", |
jtulach@169 | 40 |
"org/apidesign/vm4brwsr/Array" |
jtulach@169 | 41 |
); |
jtulach@169 | 42 |
assertTrue(ret instanceof String, "It is string: " + ret); |
jtulach@169 | 43 |
|
jtulach@169 | 44 |
assertEquals((String)ret, hotspot.toString(), "The code is the same"); |
jtulach@169 | 45 |
} |
jtulach@169 | 46 |
|
jtulach@169 | 47 |
@BeforeClass |
jtulach@169 | 48 |
public void compileTheCode() throws Exception { |
jtulach@169 | 49 |
StringBuilder sb = new StringBuilder(); |
jtulach@169 | 50 |
code = StaticMethodTest.compileClass(sb, |
jtulach@169 | 51 |
"org/apidesign/vm4brwsr/GenJS" |
jtulach@169 | 52 |
); |
jtulach@169 | 53 |
codeSeq = sb; |
jtulach@169 | 54 |
} |
jtulach@169 | 55 |
} |