@Test public void invokeMethod() throws ScriptException, NoSuchMethodException { Object obj = engine.eval("list(execute=sqrt)"); DoubleVector result = (DoubleVector) invocableEngine.invokeMethod(obj, "execute", 16); assertThat(result.length(), equalTo(1)); assertThat(result.get(0), equalTo(4d)); }
@Test public void invokeFunction() throws ScriptException, NoSuchMethodException { engine.eval("f <- function(x) sqrt(x)"); DoubleVector result = (DoubleVector) invocableEngine.invokeFunction("f", 4); assertThat(result.length(), equalTo(1)); assertThat(result.get(0), equalTo(2d)); }