use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class BinaryFunctionUnitTest method testNotFunction.
@Test
public void testNotFunction() {
BinaryFunction fun = new BinaryFunction(OperatorType.NOT);
AviatorObject result = fun.call(env, AviatorBoolean.FALSE);
assertTrue((Boolean) result.getValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class BinaryFunctionUnitTest method testSubFunction.
@Test
public void testSubFunction() {
BinaryFunction fun = new BinaryFunction(OperatorType.SUB);
AviatorObject result = fun.call(env, AviatorLong.valueOf(10L), AviatorLong.valueOf(11L));
assertEquals(-1L, (Long) result.getValue(null), 0L);
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class BinaryFunctionUnitTest method testDivFunction.
@Test
public void testDivFunction() {
BinaryFunction fun = new BinaryFunction(OperatorType.DIV);
AviatorObject result = fun.call(env, AviatorLong.valueOf(10L), AviatorLong.valueOf(11L));
assertEquals(0, (Long) result.getValue(null), 0.00);
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqFilterFunctionUnitTest method testFilter_map.
@Test
public void testFilter_map() {
Map<Integer, String> data = new HashMap<>();
for (int i = 0; i < 5; i++) {
data.put(i, "a" + i);
}
Map<String, Object> env = new HashMap<>();
SeqPredicateFunction predicate = new SeqPredicateFunction("eq_temp_1", OperatorType.EQ, new AviatorString("a1"), new AviatorString("value"));
env.putAll(AviatorEvaluator.FUNC_MAP);
env.put("eq_temp_1", predicate);
SeqFilterFunction fun = new SeqFilterFunction();
AviatorObject result = fun.call(env, AviatorRuntimeJavaType.valueOf(data), new AviatorJavaType("eq_temp_1"));
Map map = ((Map) result.getValue(null));
assertEquals(1, map.size());
for (Object value : map.values()) {
assertEquals("a1", value.toString());
}
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqIncludeFunctionUnitTest method testInclude_String.
public void testInclude_String() {
SeqIncludeFunction fun = new SeqIncludeFunction();
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"), AviatorRuntimeJavaType.valueOf("h"));
assertTrue(result.booleanValue(null));
}
Aggregations