diff -r 67e892757752 -r e8438996d406 vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Thu Oct 11 04:11:42 2012 -0700 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Thu Oct 11 10:43:17 2012 -0700 @@ -23,6 +23,7 @@ import javax.script.ScriptEngineManager; import javax.script.ScriptException; import static org.testng.Assert.*; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** Checks the basic behavior of the translator. @@ -193,17 +194,27 @@ ); } + private static CharSequence codeSeq; + private static Invocable code; + + @BeforeClass + public void compileTheCode() throws Exception { + StringBuilder sb = new StringBuilder(); + code = compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod"); + codeSeq = sb; + } + + private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception { StringBuilder sb = new StringBuilder(); - Invocable i = compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod"); Object ret = null; try { - ret = i.invokeFunction(methodName, args); + ret = code.invokeFunction(methodName, args); } catch (ScriptException ex) { - fail("Execution failed in " + sb, ex); + fail("Execution failed in\n" + codeSeq, ex); } catch (NoSuchMethodException ex) { - fail("Cannot find method in " + sb, ex); + fail("Cannot find method in\n" + codeSeq, ex); } if (ret == null && expRes == null) { return; @@ -211,7 +222,7 @@ if (expRes != null && expRes.equals(ret)) { return; } - assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb); + assertEquals(ret, expRes, msg + "was: " + ret + "\n" + codeSeq); }