2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org.apidesign.java4browser;
7 import javax.script.Invocable;
8 import javax.script.ScriptException;
9 import org.testng.annotations.Test;
10 import static org.testng.Assert.*;
14 * @author Jaroslav Tulach <jtulach@netbeans.org>
16 public class InstanceTest {
17 @Test public void verifyDefaultDoubleValue() throws Exception {
20 "org_apidesign_java4browser_Instance_defaultDblValueD",
24 @Test public void verifyAssignedByteValue() throws Exception {
26 "Will one thirty one",
27 "org_apidesign_java4browser_Instance_assignedByteValueB",
31 @Test public void verifyMagicOne() throws Exception {
33 "Should be three and something",
34 "org_apidesign_java4browser_Instance_magicOneD",
39 private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
40 StringBuilder sb = new StringBuilder();
41 Invocable i = StaticMethodTest.compileClass("Instance.class", sb);
45 ret = i.invokeFunction(methodName, args);
46 } catch (ScriptException ex) {
47 fail("Execution failed in " + sb, ex);
48 } catch (NoSuchMethodException ex) {
49 fail("Cannot find method in " + sb, ex);
51 if (ret == null && expRes == null) {
54 if (expRes.equals(ret)) {
57 assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb);