use of org.enumerable.lambda.support.groovy.LambdaGroovy.ClosureFn2 in project enumerable by hraberg.
the class GroovyTest method interactingWithJavaScript.
@Test
public void interactingWithJavaScript() throws Exception {
ScriptEngine js = JavaScriptTest.getJavaScriptEngine();
Function f = (Function) js.eval("var f = function(n, m) { return n * m; }; f;");
ClosureFn2 closure = toClosure(LambdaJavaScript.toFn2(f));
assertEquals(6.0, closure.call(new Object[] { 2, 3 }));
groovy.put("closure", closure);
assertEquals(120.0, groovy.eval("[1, 2, 3, 4, 5].inject(1, closure)"));
}
Aggregations