use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class GetVarTestCase method requireThatGetVarCanBeUsedToImplementSum.
@Test
public void requireThatGetVarCanBeUsedToImplementSum() throws ParseException {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setOutputValue(null, "in", new StringFieldValue("0;1;2;3;4;5;6;7;8;9"));
ScriptExpression.fromString("{ 0 | set_var tmp; " + " input in | split ';' | for_each { to_int + get_var tmp | set_var tmp };" + " get_var tmp | attribute out; }").execute(ctx);
FieldValue val = ctx.getInputValue("out");
assertTrue(val instanceof IntegerFieldValue);
assertEquals(45, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ArithmeticTestCase method evaluate.
private static FieldValue evaluate(Expression lhs, Operator op, Expression rhs) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new ArithmeticExpression(lhs, op, rhs).execute(ctx);
return ctx.getValue();
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class Base64DecodeTestCase method requireThatInputIsDecoded.
@Test
public void requireThatInputIsDecoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("zcIoHQ"));
new Base64DecodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof LongFieldValue);
assertEquals(489210573L, ((LongFieldValue) val).getLong());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class CatTestCase method evaluate.
private static DataType evaluate(DataType typeA, DataType typeB) {
SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("a", typeA), new Field("b", typeB));
VerificationContext ctx = new VerificationContext(adapter);
new CatExpression(new InputExpression("a"), new InputExpression("b")).verify(ctx);
return ctx.getValue();
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class CatTestCase method evaluate.
private static FieldValue evaluate(DataType typeA, FieldValue valA, DataType typeB, FieldValue valB) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter(new Field("a", typeA), new Field("b", typeB)));
ctx.setOutputValue(null, "a", valA);
ctx.setOutputValue(null, "b", valB);
new CatExpression(new InputExpression("a"), new InputExpression("b")).execute(ctx);
return ctx.getValue();
}
Aggregations