1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Sun Nov 25 17:07:51 2012 +0100
1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Sun Nov 25 23:14:58 2012 +0100
1.3 @@ -31,42 +31,42 @@
1.4 @Test public void verifyDefaultDoubleValue() throws Exception {
1.5 assertExec(
1.6 "Will be zero",
1.7 - "org_apidesign_vm4brwsr_Instance_defaultDblValueD",
1.8 + Instance.class, "defaultDblValueD",
1.9 Double.valueOf(0)
1.10 );
1.11 }
1.12 @Test public void verifyStaticMethodCall() throws Exception {
1.13 assertExec(
1.14 "Will be zero",
1.15 - "org_apidesign_vm4brwsr_InstanceSub_recallDblD",
1.16 + InstanceSub.class, "recallDblD",
1.17 Double.valueOf(0)
1.18 );
1.19 }
1.20 @Test public void verifyAssignedByteValue() throws Exception {
1.21 assertExec(
1.22 "Will one thirty one",
1.23 - "org_apidesign_vm4brwsr_Instance_assignedByteValueB",
1.24 + Instance.class, "assignedByteValueB",
1.25 Double.valueOf(31)
1.26 );
1.27 }
1.28 @Test public void verifyMagicOne() throws Exception {
1.29 assertExec(
1.30 "Should be three and something",
1.31 - "org_apidesign_vm4brwsr_Instance_magicOneD",
1.32 + Instance.class, "magicOneD",
1.33 Double.valueOf(3.3)
1.34 );
1.35 }
1.36 @Test public void verifyInstanceMethods() throws Exception {
1.37 assertExec(
1.38 "Should be eleven as we invoke overwritten method, plus 44",
1.39 - "org_apidesign_vm4brwsr_Instance_virtualBytesI",
1.40 + Instance.class, "virtualBytesI",
1.41 Double.valueOf(55)
1.42 );
1.43 }
1.44 @Test public void verifyInterfaceMethods() throws Exception {
1.45 assertExec(
1.46 "Retruns default value",
1.47 - "org_apidesign_vm4brwsr_Instance_interfaceBytesF",
1.48 + Instance.class, "interfaceBytesF",
1.49 Double.valueOf(31)
1.50 );
1.51 }
1.52 @@ -74,7 +74,7 @@
1.53 @Test public void isNull() throws Exception {
1.54 assertExec(
1.55 "Yes, we are instance",
1.56 - "org_apidesign_vm4brwsr_Instance_isNullZ",
1.57 + Instance.class, "isNullZ",
1.58 Double.valueOf(0.0)
1.59 );
1.60 }
1.61 @@ -82,7 +82,7 @@
1.62 @Test public void isInstanceOf() throws Exception {
1.63 assertExec(
1.64 "Yes, we are instance",
1.65 - "org_apidesign_vm4brwsr_Instance_instanceOfZZ",
1.66 + Instance.class, "instanceOfZZ",
1.67 Double.valueOf(1.0), true
1.68 );
1.69 }
1.70 @@ -90,7 +90,7 @@
1.71 @Test public void notInstanceOf() throws Exception {
1.72 assertExec(
1.73 "No, we are not an instance",
1.74 - "org_apidesign_vm4brwsr_Instance_instanceOfZZ",
1.75 + Instance.class, "instanceOfZZ",
1.76 Double.valueOf(0.0), false
1.77 );
1.78 }
1.79 @@ -98,14 +98,14 @@
1.80 @Test public void verifyCastToClass() throws Exception {
1.81 assertExec(
1.82 "Five signals all is good",
1.83 - "org_apidesign_vm4brwsr_Instance_castsWorkIZ",
1.84 + Instance.class, "castsWorkIZ",
1.85 Double.valueOf(5.0), false
1.86 );
1.87 }
1.88 @Test public void verifyCastToInterface() throws Exception {
1.89 assertExec(
1.90 "Five signals all is good",
1.91 - "org_apidesign_vm4brwsr_Instance_castsWorkIZ",
1.92 + Instance.class, "castsWorkIZ",
1.93 Double.valueOf(5.0), true
1.94 );
1.95 }
1.96 @@ -127,25 +127,9 @@
1.97 }
1.98
1.99 private void assertExec(
1.100 - String msg, String methodName, Object expRes, Object... args
1.101 + String msg, Class clazz, String method, Object expRes, Object... args
1.102 ) throws Exception {
1.103 -
1.104 - Object ret = null;
1.105 - try {
1.106 - ret = code.invokeFunction(methodName, args);
1.107 - } catch (ScriptException ex) {
1.108 - fail("Execution failed in\n" + StaticMethodTest.dumpJS(codeSeq), ex);
1.109 - } catch (NoSuchMethodException ex) {
1.110 - fail("Cannot find method in\n" + StaticMethodTest.dumpJS(codeSeq), ex);
1.111 - }
1.112 - if (ret == null && expRes == null) {
1.113 - return;
1.114 - }
1.115 - if (expRes.equals(ret)) {
1.116 - return;
1.117 - }
1.118 - assertEquals(ret, expRes, msg + "was: " + ret + "\n" + StaticMethodTest.dumpJS(codeSeq));
1.119 -
1.120 + StaticMethodTest.assertExec(code, codeSeq, msg, clazz, method, expRes, args);
1.121 }
1.122
1.123 }