use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqIncludeFunctionUnitTest method testInclude_Array.
@Test
public void testInclude_Array() {
Integer[] a = new Integer[3];
a[0] = 1;
a[1] = -100;
SeqIncludeFunction fun = new SeqIncludeFunction();
final AviatorObject arg1 = AviatorRuntimeJavaType.valueOf(a);
AviatorObject result = fun.call(null, arg1, AviatorRuntimeJavaType.valueOf(-100));
assertTrue(result.booleanValue(null));
// contains null Object
result = fun.call(null, arg1, AviatorNil.NIL);
assertTrue(result.booleanValue(null));
// not match
result = fun.call(null, arg1, AviatorRuntimeJavaType.valueOf(1000));
assertFalse(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqMakePredicateFunctionUnitTest method testMakePredicate.
@Test
public void testMakePredicate() {
SeqMakePredicateFunFunction fun = new SeqMakePredicateFunFunction("eq", OperatorType.EQ);
Map<String, Object> env = new HashMap<String, Object>();
AviatorObject predicateName = fun.call(env, AviatorRuntimeJavaType.valueOf("hello"));
assertNotNull(predicateName);
AviatorFunction predicate = (AviatorFunction) predicateName.getValue(env);
assertNotNull(predicate);
AviatorObject result = predicate.call(null, AviatorRuntimeJavaType.valueOf("hello"));
// equals self
assertTrue(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_gt.
@Test
public void testPredicate_gt() {
SeqPredicateFunction fun = new SeqPredicateFunction("gt", OperatorType.GT, AviatorRuntimeJavaType.valueOf("hello"));
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
assertFalse(result.booleanValue(null));
result = fun.call(null, AviatorRuntimeJavaType.valueOf("iello"));
assertTrue(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_lt.
@Test
public void testPredicate_lt() {
SeqPredicateFunction fun = new SeqPredicateFunction("lt", OperatorType.LT, AviatorRuntimeJavaType.valueOf("hello"));
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
assertFalse(result.booleanValue(null));
result = fun.call(null, AviatorRuntimeJavaType.valueOf("ae1lo"));
assertTrue(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_IllegalArguments.
@Test(expected = IllegalArgumentException.class)
public void testPredicate_IllegalArguments() {
SeqPredicateFunction fun = new SeqPredicateFunction("le", OperatorType.LE, AviatorRuntimeJavaType.valueOf("hello"));
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"), null);
}
Aggregations