blob: 7e5978846991f54eec5317afea33900923fa73f5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.expressions;
import com.yahoo.document.datatypes.IntegerFieldValue;
import com.yahoo.vespa.indexinglanguage.parser.ParseException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Simon Thoresen Hult
*/
public class CompositeExpressionTestCase {
@Test
public void requireThatToScriptBlockOutputIsParsable() throws ParseException {
Expression exp = new ConstantExpression(new IntegerFieldValue(69));
assertScript("{ 69; }", exp);
assertScript("{ 69; }", new StatementExpression(exp));
assertScript("{ 69; }", new ScriptExpression(new StatementExpression(exp)));
}
private static void assertScript(String expectedScript, Expression exp) throws ParseException {
String str = CompositeExpression.toScriptBlock(exp);
assertEquals(expectedScript, str);
assertNotNull(ScriptExpression.fromString(str));
}
}
|