use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class SetLanguageTestCase method testsettingEnglish.
@Test
public void testsettingEnglish() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("en"));
new SetLanguageExpression().execute(ctx);
assertEquals(Language.ENGLISH, ctx.getLanguage());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class SetVarTestCase method requireThatVariableTypeCanNotChange.
@Test
public void requireThatVariableTypeCanNotChange() {
VerificationContext ctx = new VerificationContext(new SimpleTestAdapter());
ctx.setValue(DataType.INT);
new SetVarExpression("out").verify(ctx);
try {
ctx.setValue(DataType.STRING);
new SetVarExpression("out").verify(ctx);
fail();
} catch (VerificationException e) {
assertTrue(e.getExpression() instanceof SetVarExpression);
assertEquals("Attempting to assign conflicting types to variable 'out', int vs string.", e.getMessage());
}
}
Aggregations