Search in sources :

Example 16 with ScriptExpression

use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.

the class ScriptParserTestCase method requireThatStatementParserCanBeInvoked.

@Test
public void requireThatStatementParserCanBeInvoked() throws ParseException {
    try {
        ScriptParser.parseStatement(newContext("foo"));
    } catch (ParseException e) {
        assertException(e, "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.");
    }
    assertEquals(new StatementExpression(new InputExpression("foo")), ScriptParser.parseStatement(newContext("input foo")));
    assertEquals(new StatementExpression(new InputExpression("foo"), new EchoExpression()), ScriptParser.parseStatement(newContext("input foo | echo")));
    assertEquals(new StatementExpression(new ScriptExpression(new StatementExpression(new InputExpression("foo")), new StatementExpression(new EchoExpression()))), ScriptParser.parseStatement(newContext("{ input foo; echo }")));
}
Also used : StatementExpression(com.yahoo.vespa.indexinglanguage.expressions.StatementExpression) EchoExpression(com.yahoo.vespa.indexinglanguage.expressions.EchoExpression) ParseException(com.yahoo.vespa.indexinglanguage.parser.ParseException) InputExpression(com.yahoo.vespa.indexinglanguage.expressions.InputExpression) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression) Test(org.junit.Test)

Aggregations

ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)16 StatementExpression (com.yahoo.vespa.indexinglanguage.expressions.StatementExpression)9 Test (org.junit.Test)8 InputExpression (com.yahoo.vespa.indexinglanguage.expressions.InputExpression)7 SDField (com.yahoo.searchdefinition.document.SDField)6 AttributeExpression (com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression)5 EchoExpression (com.yahoo.vespa.indexinglanguage.expressions.EchoExpression)5 ArithmeticExpression (com.yahoo.vespa.indexinglanguage.expressions.ArithmeticExpression)4 CatExpression (com.yahoo.vespa.indexinglanguage.expressions.CatExpression)4 ForEachExpression (com.yahoo.vespa.indexinglanguage.expressions.ForEachExpression)4 GuardExpression (com.yahoo.vespa.indexinglanguage.expressions.GuardExpression)4 IfThenExpression (com.yahoo.vespa.indexinglanguage.expressions.IfThenExpression)4 IndexExpression (com.yahoo.vespa.indexinglanguage.expressions.IndexExpression)4 ParenthesisExpression (com.yahoo.vespa.indexinglanguage.expressions.ParenthesisExpression)4 SelectInputExpression (com.yahoo.vespa.indexinglanguage.expressions.SelectInputExpression)4 SwitchExpression (com.yahoo.vespa.indexinglanguage.expressions.SwitchExpression)4 Base64DecodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64DecodeExpression)3 Base64EncodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64EncodeExpression)3 ClearStateExpression (com.yahoo.vespa.indexinglanguage.expressions.ClearStateExpression)3 GetFieldExpression (com.yahoo.vespa.indexinglanguage.expressions.GetFieldExpression)3