Search in sources :

Example 1 with FunctionFn2

use of org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2 in project enumerable by hraberg.

the class JavaScriptTest method interactingWithGroovy.

@Test
public void interactingWithGroovy() throws Exception {
    ScriptEngine groovy = GroovyTest.getGroovyEngine();
    Closure<?> closure = (Closure<?>) groovy.eval("{ n, m -> n * m }");
    FunctionFn2 f = toFunction(LambdaGroovy.toFn2(closure));
    js.put("f", f);
    assertEquals(6.0, js.eval("f(2, 3)"));
}
Also used : Closure(groovy.lang.Closure) FunctionFn2(org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2) ScriptEngine(javax.script.ScriptEngine) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) ClojureTest(org.enumerable.lambda.support.clojure.ClojureTest)

Example 2 with FunctionFn2

use of org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2 in project enumerable by hraberg.

the class JavaScriptTest method interactingWithClojure.

@Test
public void interactingWithClojure() throws Exception {
    IFn star = (IFn) ClojureTest.getClojureEngine().eval("*");
    FunctionFn2 f = toFunction(LambdaClojure.toFn2(star));
    js.put("f", f);
    assertEquals(6.0, js.eval("f(2, 3)"));
}
Also used : IFn(clojure.lang.IFn) FunctionFn2(org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) ClojureTest(org.enumerable.lambda.support.clojure.ClojureTest)

Example 3 with FunctionFn2

use of org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2 in project enumerable by hraberg.

the class JavaScriptTest method interactingWithJRuby.

@Test
public void interactingWithJRuby() throws Exception {
    ScriptEngine rb = JRubyTest.getJRubyEngine();
    RubyProc proc = (RubyProc) rb.eval(":*.to_proc");
    FunctionFn2 f = toFunction(LambdaJRuby.toFn2(proc));
    js.put("f", f);
    assertEquals(6.0, js.eval("f(2, 3)"));
}
Also used : RubyProc(org.jruby.RubyProc) FunctionFn2(org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2) ScriptEngine(javax.script.ScriptEngine) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) ClojureTest(org.enumerable.lambda.support.clojure.ClojureTest)

Aggregations

ClojureTest (org.enumerable.lambda.support.clojure.ClojureTest)3 GroovyTest (org.enumerable.lambda.support.groovy.GroovyTest)3 FunctionFn2 (org.enumerable.lambda.support.javascript.LambdaJavaScript.FunctionFn2)3 JRubyTest (org.enumerable.lambda.support.jruby.JRubyTest)3 ScalaTest (org.enumerable.lambda.support.scala.ScalaTest)3 Test (org.junit.Test)3 ScriptEngine (javax.script.ScriptEngine)2 IFn (clojure.lang.IFn)1 Closure (groovy.lang.Closure)1 RubyProc (org.jruby.RubyProc)1