use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class OptimizePredicateTestCase method requireThatPredicateOptionsAreSet.
@Test
public void requireThatPredicateOptionsAreSet() {
final Predicate predicate = Mockito.mock(Predicate.class);
final PredicateFieldValue input = new PredicateFieldValue(predicate);
ExecutionContext ctx = new ExecutionContext().setValue(input).setVariable("arity", new IntegerFieldValue(10));
new OptimizePredicateExpression((predicate1, options) -> {
assertEquals(10, options.getArity());
assertEquals(0x8000000000000000L, options.getLowerBound());
assertEquals(0x7fffffffffffffffL, options.getUpperBound());
return predicate1;
}).execute(ctx);
ctx.setVariable("upper_bound", new LongFieldValue(1000));
ctx.setVariable("lower_bound", new LongFieldValue(0));
new OptimizePredicateExpression((value, options) -> {
assertEquals(10, options.getArity());
assertEquals(0, options.getLowerBound());
assertEquals(1000, options.getUpperBound());
return value;
}).execute(ctx);
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class ScriptTestCase method requireThatVariablesReplaceOthersOutsideScript.
@Test
public void requireThatVariablesReplaceOthersOutsideScript() {
SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("out", DataType.INT));
newStatement(new SetValueExpression(new IntegerFieldValue(6)), new SetVarExpression("tmp"), newScript(newStatement(new SetValueExpression(new IntegerFieldValue(9)), new SetVarExpression("tmp"))), new GetVarExpression("tmp"), new AttributeExpression("out")).execute(adapter);
assertEquals(new IntegerFieldValue(9), adapter.getInputValue("out"));
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class ScriptTestCase method requireThatVariablesAreAvailableInScript.
@Test
public void requireThatVariablesAreAvailableInScript() {
SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("out", DataType.INT));
newScript(newStatement(new SetValueExpression(new IntegerFieldValue(69)), new SetVarExpression("tmp")), newStatement(new GetVarExpression("tmp"), new AttributeExpression("out"))).execute(adapter);
assertEquals(new IntegerFieldValue(69), adapter.getInputValue("out"));
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class ScriptTestCase method requireThatScriptEvaluatesToInputValue.
@Test
public void requireThatScriptEvaluatesToInputValue() {
SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("out", DataType.INT));
newStatement(new SetValueExpression(new IntegerFieldValue(6)), newScript(newStatement(new SetValueExpression(new IntegerFieldValue(9)))), new AttributeExpression("out")).execute(adapter);
assertEquals(new IntegerFieldValue(6), adapter.getInputValue("out"));
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class SwitchTestCase method requireThatIllegalArgumentThrows.
@Test
public void requireThatIllegalArgumentThrows() {
try {
new SwitchExpression(Collections.<String, Expression>emptyMap()).execute(new IntegerFieldValue(69));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Expected string input, got int.", e.getMessage());
}
}
Aggregations