Search in sources :

Example 86 with AviatorObject

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

the class RandomFunctionUnitTest method testCall.

@Test
public void testCall() {
    RandomFunction rand = new RandomFunction();
    AviatorObject result = rand.call(null);
    assertTrue(result instanceof AviatorDouble);
    assertFalse(result.getValue(null).equals(rand.call(null)));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) AviatorDouble(com.googlecode.aviator.runtime.type.AviatorDouble) Test(org.junit.Test)

Example 87 with AviatorObject

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

the class SysDateFunctionUnitTest method testCall.

@Test
public void testCall() {
    SysDateFunction fun = new SysDateFunction();
    AviatorObject result = fun.call(null);
    assertNotNull(result);
    assertTrue(result.getValue(null) instanceof Date);
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Date(java.util.Date) SysDateFunction(com.googlecode.aviator.runtime.function.system.SysDateFunction) Test(org.junit.Test)

Example 88 with AviatorObject

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

the class BinaryFunctionUnitTest method testMultFunction.

@Test
public void testMultFunction() {
    BinaryFunction fun = new BinaryFunction(OperatorType.MULT);
    AviatorObject result = fun.call(env, AviatorLong.valueOf(10L), AviatorLong.valueOf(11L));
    assertEquals(110L, (Long) result.getValue(null), 0L);
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Example 89 with AviatorObject

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

the class BinaryFunctionUnitTest method testNegFunction.

@Test
public void testNegFunction() {
    BinaryFunction fun = new BinaryFunction(OperatorType.NEG);
    AviatorObject result = fun.call(env, AviatorLong.valueOf(10L));
    assertEquals(-10L, (Long) result.getValue(null), 0L);
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) Test(org.junit.Test)

Example 90 with AviatorObject

use of com.googlecode.aviator.runtime.type.AviatorObject 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));
}
Also used : AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) AviatorJavaType(com.googlecode.aviator.runtime.type.AviatorJavaType) 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