Search in sources :

Example 1 with ExpressionEvaluator

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

the class ExpressionTest method testExpressionNewlineOutside.

@Test
public void testExpressionNewlineOutside() throws Exception {
    ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
    Operand o = ee.evaluate("1\n+\n1", null, null, null);
    assertEquals(2, o.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) ExpressionEvaluator(com.dexels.navajo.document.ExpressionEvaluator) CachedExpressionEvaluator(com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator) Test(org.junit.Test)

Example 2 with ExpressionEvaluator

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

the class ExpressionTest method testExpressionNewline.

@Test
public void testExpressionNewline() throws Exception {
    ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
    Operand o = ee.evaluate("'aap\nnoot'", null, null, null);
    assertEquals("aap\nnoot", o.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) ExpressionEvaluator(com.dexels.navajo.document.ExpressionEvaluator) CachedExpressionEvaluator(com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator) Test(org.junit.Test)

Example 3 with ExpressionEvaluator

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

the class ExpressionTest method testNonAscii.

@Test
public void testNonAscii() throws Exception {
    ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
    Operand o = ee.evaluate("'àáâãäåāăąæßçćĉċčèéêëēĕėęěĝğġģĥħìíîïĩīĭıįĵķĸĺļľŀłñńņňŋòóôöõøōŏőœŕŗřśŝşšţťŧùúûüũůūŭűųŵýÿŷźżž'+'àáâãäåāăąæßçćĉċčèéêëēĕėęěĝğġģĥħìíîïĩīĭıįĵķĸĺļľŀłñńņňŋòóôöõøōŏőœŕŗřśŝşšţťŧùúûüũůūŭűųŵýÿŷźżž'", null, null, null);
    assertEquals("àáâãäåāăąæßçćĉċčèéêëēĕėęěĝğġģĥħìíîïĩīĭıįĵķĸĺļľŀłñńņňŋòóôöõøōŏőœŕŗřśŝşšţťŧùúûüũůūŭűųŵýÿŷźżžàáâãäåāăąæßçćĉċčèéêëēĕėęěĝğġģĥħìíîïĩīĭıįĵķĸĺļľŀłñńņňŋòóôöõøōŏőœŕŗřśŝşšţťŧùúûüũůūŭűųŵýÿŷźżž", o.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) ExpressionEvaluator(com.dexels.navajo.document.ExpressionEvaluator) CachedExpressionEvaluator(com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator) Test(org.junit.Test)

Example 4 with ExpressionEvaluator

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

the class ExpressionTest method testExpression.

@Test
public void testExpression() throws Exception {
    ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
    Operand o = ee.evaluate("1+1", null, null, null);
    assertEquals(2, o.value);
    o = ee.evaluate("TODAY + 0#0#2#0#0#0", null, null, null);
    System.err.println(o.value);
    Navajo testDoc = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
    testDoc.addMessage(m);
    Message a = NavajoFactory.getInstance().createMessage(testDoc, "MyArrayMessage", "array");
    m.addMessage(a);
    for (int i = 0; i < 5; i++) {
        Message a1 = NavajoFactory.getInstance().createMessage(testDoc, "MyArrayMessage");
        a.addMessage(a1);
        Property p = NavajoFactory.getInstance().createProperty(testDoc, "MyProp", "string", "noot" + i, 0, "", "in");
        a1.addProperty(p);
        Property p2 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp2", "string", "aap" + i, 0, "", "in");
        a1.addProperty(p2);
    }
    o = ee.evaluate("'hallo:' + [/MyTop/MyArrayMessage@MyProp=noot1/MyProp2]", testDoc, null, null);
    assertEquals("hallo:aap1", o.value);
    o = ee.evaluate("'hallo:' + [/MyTop/MyArrayMessage@2/MyProp2]", testDoc, null, null);
    assertEquals("hallo:aap2", o.value);
}
Also used : ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Message(com.dexels.navajo.document.Message) Operand(com.dexels.navajo.document.Operand) Navajo(com.dexels.navajo.document.Navajo) ExpressionEvaluator(com.dexels.navajo.document.ExpressionEvaluator) CachedExpressionEvaluator(com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 5 with ExpressionEvaluator

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

the class ExpressionTest method testUnicode.

@Test
public void testUnicode() throws Exception {
    ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
    Operand o = ee.evaluate("'ø'+'æ'", null, null, null);
    assertEquals("øæ", o.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) ExpressionEvaluator(com.dexels.navajo.document.ExpressionEvaluator) CachedExpressionEvaluator(com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator) Test(org.junit.Test)

Aggregations

ExpressionEvaluator (com.dexels.navajo.document.ExpressionEvaluator)5 Operand (com.dexels.navajo.document.Operand)5 CachedExpressionEvaluator (com.dexels.navajo.parser.compiled.api.CachedExpressionEvaluator)5 Test (org.junit.Test)5 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)1 Message (com.dexels.navajo.document.Message)1 Navajo (com.dexels.navajo.document.Navajo)1 Property (com.dexels.navajo.document.Property)1