aboutsummaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-04-14 13:52:07 +0200
committerJon Bratseth <bratseth@gmail.com>2023-04-14 13:52:07 +0200
commit057fa96d6776e275efbb4c5ed0d758277985338a (patch)
tree8a40aeae1a30655144dea9b43c99c8222ed72973 /indexinglanguage/src/test
parenta2d73b3942d48015a0e52fe1163e5e0c27aa2316 (diff)
Resolve parent before children
Diffstat (limited to 'indexinglanguage/src/test')
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/ChoiceTestCase.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/ChoiceTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/ChoiceTestCase.java
index 7ece841e9b7..e6d5c550e93 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/ChoiceTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/ChoiceTestCase.java
@@ -2,7 +2,9 @@
package com.yahoo.vespa.indexinglanguage.expressions;
import com.yahoo.document.DataType;
+import com.yahoo.document.Document;
import com.yahoo.document.Field;
+import com.yahoo.document.datatypes.LongFieldValue;
import com.yahoo.document.datatypes.StringFieldValue;
import com.yahoo.language.Linguistics;
import com.yahoo.language.process.Embedder;
@@ -44,6 +46,7 @@ public class ChoiceTestCase {
var adapter = new SimpleTestAdapter(new Field("foo", DataType.STRING), new Field("bar", DataType.STRING));
adapter.setValue("foo", new StringFieldValue("foo1"));
adapter.setValue("bar", new StringFieldValue("bar1"));
+ choice.verify(adapter);
ExecutionContext context = new ExecutionContext(adapter);
choice.execute(context);
assertEquals("foo1", context.getValue().getWrappedValue());
@@ -51,6 +54,28 @@ public class ChoiceTestCase {
}
@Test
+ public void testChoiceWithConstant() throws ParseException {
+ var choice = parse("input timestamp || 99999999L | attribute timestamp");
+
+ { // value is set
+ var adapter = new SimpleTestAdapter(new Field("timestamp", DataType.LONG));
+ choice.verify(adapter);
+ adapter.setValue("timestamp", new LongFieldValue(34));
+ ExecutionContext context = new ExecutionContext(adapter);
+ choice.execute(context);
+ assertEquals(34L, context.getValue().getWrappedValue());
+ }
+
+ { // fallback to default
+ var adapter = new SimpleTestAdapter(new Field("timestamp", DataType.LONG));
+ choice.verify(adapter);
+ ExecutionContext context = new ExecutionContext(adapter);
+ choice.execute(context);
+ assertEquals(99999999L, context.getValue().getWrappedValue());
+ }
+ }
+
+ @Test
public void testIllegalChoiceExpression() throws ParseException {
try {
parse("input (foo || 99999999) | attribute");