Flush mapper before pushing back a result of (virtual) method invocation. The static method call was already doing that.
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.vm4brwsr;
20 import javax.script.ScriptEngine;
21 import javax.script.ScriptEngineManager;
22 import static org.testng.Assert.fail;
23 import org.testng.annotations.AfterClass;
24 import org.testng.annotations.BeforeClass;
25 import org.testng.annotations.Test;
29 * @author Jaroslav Tulach <jtulach@netbeans.org>
31 public class InstanceTest {
32 @Test public void verifyDefaultDoubleValue() throws Exception {
35 Instance.class, "defaultDblValue__D",
39 @Test public void verifyStaticMethodCall() throws Exception {
42 InstanceSub.class, "recallDbl__D",
46 @Test public void verifyAssignedByteValue() throws Exception {
48 "Will one thirty one",
49 Instance.class, "assignedByteValue__B",
53 @Test public void noInstOfExposed() throws Exception {
55 "No instOf properties found",
56 Instance.class, "noInstOfExposed__I",
60 @Test public void noIterablePropsOnObject() throws Exception {
62 "No instOf properties found",
63 Instance.class, "props__Ljava_lang_String_2",
68 @Test public void verifyMagicOne() throws Exception {
70 "Should be three and something",
71 Instance.class, "magicOne__D",
75 @Test public void verifyInstanceMethods() throws Exception {
77 "Should be eleven as we invoke overwritten method, plus 44",
78 Instance.class, "virtualBytes__I",
82 @Test public void verifyInterfaceMethods() throws Exception {
84 "Retruns default value",
85 Instance.class, "interfaceBytes__F",
90 @Test public void isNull() throws Exception {
92 "Yes, we are instance",
93 Instance.class, "isNull__Z",
98 @Test public void isInstanceOf() throws Exception {
100 "Yes, we are instance",
101 Instance.class, "instanceOf__ZI",
102 Double.valueOf(1.0), 2
106 @Test public void notInstanceOf() throws Exception {
108 "No, we are not an instance",
109 Instance.class, "instanceOf__ZI",
110 Double.valueOf(0.0), 1
113 @Test public void nullInstanceOf() throws Exception {
115 "No, null is not an instance",
116 Instance.class, "instanceOf__ZI",
117 Double.valueOf(0.0), 0
121 @Test public void verifyCastToClass() throws Exception {
123 "Five signals all is good",
124 Instance.class, "castsWork__IZ",
125 Double.valueOf(5.0), false
128 @Test public void verifyCastToInterface() throws Exception {
130 "Five signals all is good",
131 Instance.class, "castsWork__IZ",
132 Double.valueOf(5.0), true
136 @Test public void sharedConstructor() throws Exception {
138 "Constructor of first and 2nd instance should be the same",
139 Instance.class, "sharedConstructor__Z",
144 @Test public void differentConstructor() throws Exception {
146 "Constructor of X and Y should be the different",
147 Instance.class, "differentConstructor__Z",
152 @Test public void jsObjectIsLikeJavaObject() throws Exception {
154 "JavaScript object is instance of Java Object",
155 Instance.class, "iofObject__Z",
160 @Test public void jsCallingConvention() throws Exception {
162 "Pointer to 'this' is passed automatically (and not as a first argument)",
163 Instance.class, "jscall__I",
168 protected String startCompilationWith() {
169 return "org/apidesign/vm4brwsr/Instance";
172 private static TestVM code;
175 public void compileTheCode() throws Exception {
176 code = TestVM.compileClass(startCompilationWith());
179 public static void releaseTheCode() {
183 private void assertExec(
184 String msg, Class clazz, String method, Object expRes, Object... args
186 code.assertExec(msg, clazz, method, expRes, args);