Search in sources :

Example 36 with ContextExpression

use of com.dexels.navajo.expression.api.ContextExpression in project navajo by Dexels.

the class TestCompiledExpression method testFunctionParamTypeError.

@Test
public void testFunctionParamTypeError() throws TMLExpressionException {
    List<String> problems = new ArrayList<>();
    ContextExpression o = ExpressionCache.getInstance().parse(problems, "ToUpper(1)", name -> FunctionClassification.DEFAULT);
    System.err.println("problems: " + problems);
    System.err.println("returntype: " + o.returnType());
    System.err.println("immutable: " + o.isLiteral());
    if (RuntimeConfig.STRICT_TYPECHECK.getValue() != null) {
        Assert.assertEquals(1, problems.size());
    } else {
        Assert.assertEquals("Don't expect problems to appear when STRICT_TYPECHECK is false", 0, problems.size());
    // Assert.fail("Failed test, ony valid when STRICT_TYPECHECK. Set env for unit tests.");
    }
}
Also used : ContextExpression(com.dexels.navajo.expression.api.ContextExpression) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ContextExpression (com.dexels.navajo.expression.api.ContextExpression)36 ArrayList (java.util.ArrayList)25 Test (org.junit.Test)18 Operand (com.dexels.navajo.document.Operand)14 Message (com.dexels.navajo.document.Message)13 Navajo (com.dexels.navajo.document.Navajo)13 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)13 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)12 Selection (com.dexels.navajo.document.Selection)12 TipiLink (com.dexels.navajo.expression.api.TipiLink)12 Access (com.dexels.navajo.script.api.Access)12 Optional (java.util.Optional)12 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)9 ExpressionCache (com.dexels.navajo.parser.compiled.api.ExpressionCache)7 StringReader (java.io.StringReader)7 FunctionClassification (com.dexels.navajo.expression.api.FunctionClassification)4 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)4 NamedExpression (com.dexels.navajo.parser.NamedExpression)4 List (java.util.List)4 Function (java.util.function.Function)4