Search in sources :

Example 1 with JexlEngine

use of cn.hutool.extra.expression.engine.jexl.JexlEngine in project hutool by looly.

the class ExpressionUtilTest method jexlTest.

@Test
public void jexlTest() {
    ExpressionEngine engine = new JexlEngine();
    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 : JexlEngine(cn.hutool.extra.expression.engine.jexl.JexlEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Example 2 with JexlEngine

use of cn.hutool.extra.expression.engine.jexl.JexlEngine in project hutool by dromara.

the class ExpressionUtilTest method jexlTest.

@Test
public void jexlTest() {
    ExpressionEngine engine = new JexlEngine();
    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 : JexlEngine(cn.hutool.extra.expression.engine.jexl.JexlEngine) Dict(cn.hutool.core.lang.Dict) Test(org.junit.Test)

Aggregations

Dict (cn.hutool.core.lang.Dict)2 JexlEngine (cn.hutool.extra.expression.engine.jexl.JexlEngine)2 Test (org.junit.Test)2