use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class MathRoundFunctionUnitTest method testCall.
@Test
public void testCall() {
assertEquals(Math.round(30), this.function.call(null, AviatorNumber.valueOf(30)).getValue(null));
assertEquals(Math.round(1020.999), this.function.call(null, AviatorNumber.valueOf(1020.999)).getValue(null));
assertEquals(Math.round(400), this.function.call(null, AviatorNumber.valueOf(400)).getValue(null));
Map<String, Object> env = new HashMap<String, Object>();
env.put("a", 10000);
env.put("b", 9.0);
assertEquals(Math.round(10000), this.function.call(env, new AviatorJavaType("a")).getValue(null));
assertEquals(Math.round(9.0), this.function.call(env, new AviatorJavaType("b")).getValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class MathSqrtFunctionUnitTest method testCall.
@Test
public void testCall() {
assertEquals(3.0, this.function.call(null, AviatorNumber.valueOf(9)).getValue(null));
assertEquals(9.0, this.function.call(null, AviatorNumber.valueOf(81)).getValue(null));
assertEquals(20.0, this.function.call(null, AviatorNumber.valueOf(400)).getValue(null));
Map<String, Object> env = new HashMap<String, Object>();
env.put("a", 400);
env.put("b", 9.0);
assertEquals(20.0, this.function.call(env, new AviatorJavaType("a")).getValue(null));
assertEquals(3.0, this.function.call(env, new AviatorJavaType("b")).getValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class FunctionUtilsUnitTest method testGetFunction_neg.
@Test
public void testGetFunction_neg() {
AviatorFunction fun = FunctionUtils.getFunction(new AviatorJavaType("-"), AviatorEvaluator.FUNC_MAP, 1);
assertNotNull(fun);
assertTrue(fun instanceof BinaryFunction);
assertEquals("-neg", fun.getName());
assertEquals(OperatorType.NEG, ((BinaryFunction) fun).getOpType());
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class FunctionUtilsUnitTest method testGetFunction_sub.
@Test
public void testGetFunction_sub() {
AviatorFunction fun = FunctionUtils.getFunction(new AviatorJavaType("-"), AviatorEvaluator.FUNC_MAP, 2);
assertNotNull(fun);
assertTrue(fun instanceof BinaryFunction);
assertEquals("-sub", fun.getName());
assertEquals(OperatorType.SUB, ((BinaryFunction) fun).getOpType());
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class FunctionUtilsUnitTest method testGetFunction_Normal.
@Test
public void testGetFunction_Normal() {
AviatorFunction fun = FunctionUtils.getFunction(new AviatorJavaType("map"), AviatorEvaluator.FUNC_MAP, 2);
assertNotNull(fun);
assertTrue(fun instanceof SeqMapFunction);
}
Aggregations