Search in sources :

Example 81 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.

the class SeqPredicateFunctionUnitTest method testPredicate_neq.

@Test
public void testPredicate_neq() {
    SeqPredicateFunction fun = new SeqPredicateFunction("neq", OperatorType.NEQ, AviatorRuntimeJavaType.valueOf("hello"));
    AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
    assertFalse(result.booleanValue(null));
    result = fun.call(null, AviatorRuntimeJavaType.valueOf("he1lo"));
    assertTrue(result.booleanValue(null));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Example 82 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.

the class SeqCountFunctionUnitTest method testCount_Collection.

@Test
public void testCount_Collection() {
    final HashSet<Integer> set = new HashSet<Integer>();
    set.add(1);
    set.add(2);
    SeqCountFunction fun = new SeqCountFunction();
    AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf(set));
    assertEquals(2, result.getValue(null));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 83 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.

the class SeqCountFunctionUnitTest method testCount_EmptyArray.

@Test
public void testCount_EmptyArray() {
    SeqCountFunction fun = new SeqCountFunction();
    AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf(new String[0]));
    assertEquals(0, result.getValue(null));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Example 84 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.

the class SeqCountFunctionUnitTest method testCount_Array.

@Test
public void testCount_Array() {
    AviatorObject[] args = new AviatorObject[1];
    args[0] = AviatorRuntimeJavaType.valueOf(new String[10]);
    SeqCountFunction fun = new SeqCountFunction();
    AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf(new String[10]));
    assertEquals(10, result.getValue(null));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Example 85 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.

the class SeqCountFunctionUnitTest method testCount_String.

@Test
public void testCount_String() {
    SeqCountFunction fun = new SeqCountFunction();
    AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
    assertEquals(5, result.getValue(null));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Aggregations

AviatorObject (com.googlecode.aviator.runtime.type.AviatorObject)110 Test (org.junit.Test)51 AviatorJavaType (com.googlecode.aviator.runtime.type.AviatorJavaType)25 AviatorString (com.googlecode.aviator.runtime.type.AviatorString)22 AviatorFunction (com.googlecode.aviator.runtime.type.AviatorFunction)16 HashMap (java.util.HashMap)12 Map (java.util.Map)11 List (java.util.List)10 AbstractFunction (com.googlecode.aviator.runtime.function.AbstractFunction)9 FunctionNotFoundException (com.googlecode.aviator.exception.FunctionNotFoundException)7 Env (com.googlecode.aviator.utils.Env)6 ExpressionRuntimeException (com.googlecode.aviator.exception.ExpressionRuntimeException)5 LinkedList (java.util.LinkedList)5 Collection (java.util.Collection)4 NumberToken (com.googlecode.aviator.lexer.token.NumberToken)3 AviatorPattern (com.googlecode.aviator.runtime.type.AviatorPattern)3 AviatorRuntimeJavaType (com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType)3 Sequence (com.googlecode.aviator.runtime.type.Sequence)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3