use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.
the class TestCompiledExpression method testFunctionType.
@Test
public void testFunctionType() {
ExpressionCache ce = ExpressionCache.getInstance();
List<String> problems = new ArrayList<>();
ContextExpression cx = ce.parse(problems, "ToUpper([whatever])", name -> FunctionClassification.DEFAULT);
Assert.assertEquals(Property.STRING_PROPERTY, cx.returnType().get());
}
use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.
the class TestTypeCheckCompiledExpressionEvaluator method testEquals.
@Test
public void testEquals() {
ExpressionCache ce = ExpressionCache.getInstance();
List<String> problems = new ArrayList<>();
ContextExpression cx = ce.parse(problems, "1==1", fn -> FunctionClassification.DEFAULT);
Assert.assertEquals(Property.BOOLEAN_PROPERTY, cx.returnType().get());
}
use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.
the class TestTypeCheckCompiledExpressionEvaluator method testUnknown.
@Test
public void testUnknown() {
// test unknowable type
ExpressionCache ce = ExpressionCache.getInstance();
List<String> problems = new ArrayList<>();
ContextExpression cx = ce.parse(problems, "[bla]", fn -> FunctionClassification.DEFAULT);
Assert.assertFalse(cx.returnType().isPresent());
}
use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.
the class TestTypeCheckCompiledExpressionEvaluator method testBadType.
@Test
public void testBadType() {
// test unknowable type
ExpressionCache ce = ExpressionCache.getInstance();
List<String> problems = new ArrayList<>();
// the [] expression has been added to prevent the expression to be pre-evaluated (as all other params are literals
ContextExpression cx = ce.parse(problems, "1 AND 'monkey' AND [whoop]", fn -> FunctionClassification.DEFAULT);
System.err.println("Problems: " + problems);
Assert.assertEquals(2, problems.size());
Assert.assertEquals(Property.BOOLEAN_PROPERTY, cx.returnType().get());
}
use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.
the class TestTypeCheckCompiledExpressionEvaluator method testBasicTypes.
@Test
public void testBasicTypes() {
ExpressionCache ce = ExpressionCache.getInstance();
List<String> problems = new ArrayList<>();
ContextExpression cx = ce.parse(problems, "1", fn -> FunctionClassification.DEFAULT);
Assert.assertEquals(Property.INTEGER_PROPERTY, cx.returnType().get());
}
Aggregations