use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class SeqMapFunctionUnitTest method testMap_String.
@Test
public void testMap_String() {
Env env = TestUtils.getTestEnv();
SeqMapFunction fun = new SeqMapFunction();
AviatorObject result = fun.call(env, AviatorRuntimeJavaType.valueOf("hello"), new AviatorJavaType("string.length"));
List list = (List) result.getValue(null);
assertEquals(5, list.size());
for (Object val : list) {
assertEquals(val, 1);
}
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class MathLogFunctionUnitTest method testCall.
@Test
public void testCall() {
Env env = TestUtils.getTestEnv();
assertEquals(2.197, this.function.call(env, AviatorNumber.valueOf(9)).getValue(null));
assertEquals(4.394, this.function.call(env, AviatorNumber.valueOf(81)).getValue(null));
assertEquals(5.991, this.function.call(env, AviatorNumber.valueOf(400)).getValue(null));
assertEquals(new BigDecimal("5.991464547107981986870447152285084"), this.function.call(env, AviatorNumber.valueOf(new BigInteger("400"))).getValue(null));
assertEquals(new BigDecimal("6.907755268982137002053974030719759"), this.function.call(env, AviatorNumber.valueOf(new BigDecimal("999.99999"))).getValue(null));
env.put("a", 400);
env.put("b", 9.0);
assertEquals(5.991, this.function.call(env, new AviatorJavaType("a")).getValue(null));
assertEquals(2.197, this.function.call(env, new AviatorJavaType("b")).getValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorJavaType in project aviatorscript by killme2008.
the class MathSinFunctionUnitTest method testCall.
@Test
public void testCall() {
assertEquals(Math.sin(30), this.function.call(null, AviatorNumber.valueOf(30)).getValue(null));
assertEquals(Math.sin(1020.999), this.function.call(null, AviatorNumber.valueOf(1020.999)).getValue(null));
assertEquals(Math.sin(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.sin(10000), this.function.call(env, new AviatorJavaType("a")).getValue(null));
assertEquals(Math.sin(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 MathTanFunctionUnitTest method testCall.
@Test
public void testCall() {
assertEquals(Math.tan(30), this.function.call(null, AviatorNumber.valueOf(30)).getValue(null));
assertEquals(Math.tan(1020.999), this.function.call(null, AviatorNumber.valueOf(1020.999)).getValue(null));
assertEquals(Math.tan(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.tan(10000), this.function.call(env, new AviatorJavaType("a")).getValue(null));
assertEquals(Math.tan(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 SeqReduceFunctionUnitTest method testReduce_NullArray.
@Test(expected = ExpressionRuntimeException.class)
public void testReduce_NullArray() {
Integer[] a = new Integer[10];
for (int i = 0; i < a.length; i++) {
if (i % 2 == 0) {
a[i] = i;
}
}
SeqReduceFunction fun = new SeqReduceFunction();
AviatorObject result = fun.call(this.env, AviatorRuntimeJavaType.valueOf(a), new AviatorJavaType("+"), AviatorRuntimeJavaType.valueOf(0));
}
Aggregations