Search in sources :

Example 1 with RhinoEngine

use of cn.hutool.extra.expression.engine.rhino.RhinoEngine in project hutool by looly.

the class ExpressionUtilTest method rhinoTest.

@Test
public void rhinoTest() {
    ExpressionEngine engine = new RhinoEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : Dict(cn.hutool.core.lang.Dict) RhinoEngine(cn.hutool.extra.expression.engine.rhino.RhinoEngine) Test(org.junit.Test)

Example 2 with RhinoEngine

use of cn.hutool.extra.expression.engine.rhino.RhinoEngine in project hutool by dromara.

the class ExpressionUtilTest method rhinoTest.

@Test
public void rhinoTest() {
    ExpressionEngine engine = new RhinoEngine();
    final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
    final Object eval = engine.eval("a-(b-c)", dict);
    Assert.assertEquals(-143.8, (double) eval, 2);
}
Also used : Dict(cn.hutool.core.lang.Dict) RhinoEngine(cn.hutool.extra.expression.engine.rhino.RhinoEngine) Test(org.junit.Test)

Aggregations

Dict (cn.hutool.core.lang.Dict)2 RhinoEngine (cn.hutool.extra.expression.engine.rhino.RhinoEngine)2 Test (org.junit.Test)2