aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java
diff options
context:
space:
mode:
authorLester Solbakken <lesters@oath.com>2018-09-10 15:22:08 +0200
committerLester Solbakken <lesters@oath.com>2018-09-10 15:22:08 +0200
commit33c0861f6871f5593885b9c7884b60436780e228 (patch)
tree4e33c462520ee0246ff41b23dfb88032fbbd2697 /config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java
parenta7066e7028de1f35264bbfe164ba950ba5c6752f (diff)
Don't detect rank expression loops on bound identifiers
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java
index c843023d518..df9a40d29e2 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java
@@ -3,7 +3,6 @@ package com.yahoo.searchdefinition;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.yolean.Exceptions;
-import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -15,7 +14,6 @@ import static org.junit.Assert.fail;
public class RankingExpressionLoopDetectionTestCase {
@Test
- @Ignore // TODO
public void testSelfLoop() throws ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
@@ -48,7 +46,6 @@ public class RankingExpressionLoopDetectionTestCase {
}
@Test
- @Ignore // TODO
public void testNestedLoop() throws ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
@@ -84,7 +81,6 @@ public class RankingExpressionLoopDetectionTestCase {
}
@Test
- @Ignore // TODO
public void testSelfArgumentLoop() throws ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
@@ -114,7 +110,7 @@ public class RankingExpressionLoopDetectionTestCase {
fail("Excepted exception");
}
catch (IllegalArgumentException e) {
- assertEquals("In search definition 'test', rank profile 'test': The first-phase expression is invalid: Invocation loop: foo -> arg(foo) -> a1 -> foo",
+ assertEquals("In search definition 'test', rank profile 'test': The first-phase expression is invalid: Invocation loop: foo -> arg(foo) -> foo",
Exceptions.toMessageString(e));
}
}
@@ -175,4 +171,27 @@ public class RankingExpressionLoopDetectionTestCase {
builder.build();
}
+ @Test
+ public void testNoLoopWithBoundIdentifiers() throws ParseException {
+ RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
+ SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
+ builder.importString(
+ "search test {\n" +
+ " document test { \n" +
+ " }\n" +
+ " rank-profile test {\n" +
+ " first-phase {\n" +
+ " expression: foo(bar(2))\n" +
+ " }\n" +
+ " macro foo(x) {\n" +
+ " expression: x * x\n" +
+ " }\n" +
+ " macro bar(x) {\n" +
+ " expression: x + x\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ builder.build();
+ }
+
}