Search in sources :

Example 66 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledExpression method testUnicodeExpressionEscaped.

@Test
public void testUnicodeExpressionEscaped() throws Exception {
    Operand result = Expression.evaluate("'\u20AC2,29'", null, null, null);
    Assert.assertEquals("€2,29", result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 67 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledExpression method testDoubleIntegerComparison.

@Test
public void testDoubleIntegerComparison() {
    Operand result;
    result = Expression.evaluate(" 0.9 < 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 1.0 < 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 0.9 <= 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 1.0 <= 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 0.9 > 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1.0 > 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 0.9 >= 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1.0 >= 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 68 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledExpression method testIntegerComparison.

@Test
public void testIntegerComparison() {
    Operand result;
    result = Expression.evaluate(" 1 < 2 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 1 < 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1 <= 2 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 1 <= 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
    result = Expression.evaluate(" 1 > 2 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1 > 1 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1 >= 2 ", null, null, null);
    Assert.assertFalse((boolean) result.value);
    result = Expression.evaluate(" 1 >= 1 ", null, null, null);
    Assert.assertTrue((boolean) result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 69 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestExpressionPropertiesCompiled method testCompiled.

@Test
public void testCompiled() throws TMLExpressionException, SystemException {
    Operand result = Expression.evaluate("[Two]", testDoc, null, topMessage);
    Assert.assertEquals(2, result.value);
    Integer twoValue = (Integer) two.getTypedValue();
    Assert.assertEquals(2, twoValue.intValue());
    one.setAnyValue(2);
    Integer fiveValue = (Integer) five.getTypedValue();
    Assert.assertEquals(5, fiveValue.intValue());
    List<Property> change = testDoc.refreshExpression();
    twoValue = (Integer) two.getTypedValue();
    Assert.assertEquals(3, twoValue.intValue());
    System.err.println("Change: " + change.size());
    result = Expression.evaluate("[Two]", testDoc, null, topMessage);
    Assert.assertEquals(3, result.value);
    fiveValue = (Integer) five.getTypedValue();
    Assert.assertEquals(6, fiveValue.intValue());
}
Also used : Operand(com.dexels.navajo.document.Operand) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 70 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class ExpressionTest method testEmptySlashTMLParam.

@Test
public void testEmptySlashTMLParam() throws Exception {
    Expression.compileExpressions = true;
    ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
    Operand o = Expression.evaluateImmutable("[/@]", null, Optional.empty(), Optional.of(outer));
    ImmutableMessage s = o.immutableMessageValue();
    assertEquals(outer, s);
}
Also used : Operand(com.dexels.navajo.document.Operand) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Aggregations

Operand (com.dexels.navajo.document.Operand)95 Test (org.junit.Test)57 Message (com.dexels.navajo.document.Message)22 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)20 Navajo (com.dexels.navajo.document.Navajo)20 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)15 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)14 ArrayList (java.util.ArrayList)12 Selection (com.dexels.navajo.document.Selection)11 Property (com.dexels.navajo.document.Property)10 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)10 Access (com.dexels.navajo.script.api.Access)10 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)10 NavajoException (com.dexels.navajo.document.NavajoException)9 TipiLink (com.dexels.navajo.expression.api.TipiLink)9 Optional (java.util.Optional)9 FunctionDefinition (com.dexels.navajo.expression.api.FunctionDefinition)8 GiveLongTestFunction (com.dexels.navajo.expression.compiled.GiveLongTestFunction)6 SystemException (com.dexels.navajo.script.api.SystemException)6 List (java.util.List)6