aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/test
diff options
context:
space:
mode:
authorLester Solbakken <lesters@oath.com>2021-03-16 12:11:26 +0100
committerLester Solbakken <lesters@oath.com>2021-03-16 12:11:26 +0100
commita72c0d645fcf7dcf9225d9e13a16b3bc0434c6ca (patch)
treef2a58b3268c39ecd4686d2408dc09b0274c67435 /searchlib/src/test
parentf59e36dd56d18f1148a0665823c0dfe7e40dd805 (diff)
Add Java-side tensor type cell casting
Diffstat (limited to 'searchlib/src/test')
-rw-r--r--searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTestCase.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTestCase.java b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTestCase.java
index 123fa5ac43b..fae5a7a093c 100644
--- a/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTestCase.java
+++ b/searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationTestCase.java
@@ -394,6 +394,23 @@ public class EvaluationTestCase {
}
@Test
+ public void testCellTypeCasting() {
+ EvaluationTester tester = new EvaluationTester();
+
+ tester.assertEvaluates("tensor<float>(x[3]):[1.0, 2.0, 3.0]",
+ "cell_cast(tensor0, float)",
+ "tensor<double>(x[3]):[1, 2, 3]");
+ tester.assertEvaluates("tensor<float>():{1}",
+ "cell_cast(tensor0{x:1}, float)",
+ "tensor<double>(x{}):{1:1, 2:2, 3:3}");
+ tester.assertEvaluates("tensor<float>(x[2]):[3,8]",
+ "cell_cast(tensor0 * tensor1, float)",
+ "tensor<float>(x[2]):[1,2]",
+ "tensor<double>(x[2]):[3,4]");
+ }
+
+
+ @Test
public void testMixedTensorType() throws ParseException {
String expected = "tensor(x[1],y{},z[2]):{{x:0,y:a,z:0}:4.0,{x:0,y:a,z:1}:5.0,{x:0,y:b,z:0}:7.0,{x:0,y:b,z:1}:8.0}";
String a = "tensor(x[1],y{}):{ {x:0,y:a}:1, {x:0,y:b}:2 }";