Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 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 org.testng.annotations.Test;
21 import org.testng.annotations.BeforeClass;
25 * @author Jaroslav Tulach <jtulach@netbeans.org>
27 public class InstanceTest {
28 @Test public void verifyDefaultDoubleValue() throws Exception {
31 Instance.class, "defaultDblValue__D",
35 @Test public void verifyStaticMethodCall() throws Exception {
38 InstanceSub.class, "recallDbl__D",
42 @Test public void verifyAssignedByteValue() throws Exception {
44 "Will one thirty one",
45 Instance.class, "assignedByteValue__B",
49 @Test public void verifyMagicOne() throws Exception {
51 "Should be three and something",
52 Instance.class, "magicOne__D",
56 @Test public void verifyInstanceMethods() throws Exception {
58 "Should be eleven as we invoke overwritten method, plus 44",
59 Instance.class, "virtualBytes__I",
63 @Test public void verifyInterfaceMethods() throws Exception {
65 "Retruns default value",
66 Instance.class, "interfaceBytes__F",
71 @Test public void isNull() throws Exception {
73 "Yes, we are instance",
74 Instance.class, "isNull__Z",
79 @Test public void isInstanceOf() throws Exception {
81 "Yes, we are instance",
82 Instance.class, "instanceOf__ZI",
83 Double.valueOf(1.0), 2
87 @Test public void notInstanceOf() throws Exception {
89 "No, we are not an instance",
90 Instance.class, "instanceOf__ZI",
91 Double.valueOf(0.0), 1
94 @Test public void nullInstanceOf() throws Exception {
96 "No, null is not an instance",
97 Instance.class, "instanceOf__ZI",
98 Double.valueOf(0.0), 0
102 @Test public void verifyCastToClass() throws Exception {
104 "Five signals all is good",
105 Instance.class, "castsWork__IZ",
106 Double.valueOf(5.0), false
109 @Test public void verifyCastToInterface() throws Exception {
111 "Five signals all is good",
112 Instance.class, "castsWork__IZ",
113 Double.valueOf(5.0), true
117 @Test public void sharedConstructor() throws Exception {
119 "Constructor of first and 2nd instance should be the same",
120 Instance.class, "sharedConstructor__Z",
125 @Test public void differentConstructor() throws Exception {
127 "Constructor of X and Y should be the different",
128 Instance.class, "differentConstructor__Z",
133 @Test public void jsObjectIsLikeJavaObject() throws Exception {
135 "JavaScript object is instance of Java Object",
136 Instance.class, "iofObject__Z",
141 @Test public void jsCallingConvention() throws Exception {
143 "Pointer to 'this' is passed automatically (and not as a first argument)",
144 Instance.class, "jscall__I",
149 protected String startCompilationWith() {
150 return "org/apidesign/vm4brwsr/Instance";
153 private static TestVM code;
156 public void compileTheCode() throws Exception {
157 code = TestVM.compileClass(startCompilationWith());
160 private void assertExec(
161 String msg, Class clazz, String method, Object expRes, Object... args
163 code.assertExec(msg, clazz, method, expRes, args);