1 package org.apidesign.vm4brwsr;
3 import javax.script.Invocable;
4 import javax.script.ScriptException;
5 import org.testng.annotations.Test;
6 import static org.testng.Assert.*;
10 * @author Jaroslav Tulach <jtulach@netbeans.org>
12 public class StringTest {
13 @Test public void firstChar() throws Exception {
15 "First char in Hello is H",
16 "org_apidesign_vm4brwsr_StringSample_sayHelloCI",
17 Double.valueOf((int)'H'), 0
21 private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
22 StringBuilder sb = new StringBuilder();
23 Invocable i = StaticMethodTest.compileClass(sb,
24 "org/apidesign/vm4brwsr/StringSample",
30 ret = i.invokeFunction(methodName, args);
31 } catch (ScriptException ex) {
32 fail("Execution failed in " + sb, ex);
33 } catch (NoSuchMethodException ex) {
34 fail("Cannot find method in " + sb, ex);
36 if (ret == null && expRes == null) {
39 if (expRes.equals(ret)) {
42 assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb);