|
49 | 49 | import dev.cel.expr.conformance.proto3.TestAllTypes.NestedMessage; |
50 | 50 | import dev.cel.parser.CelMacro; |
51 | 51 | import dev.cel.parser.CelStandardMacro; |
| 52 | +import dev.cel.runtime.CelAttributePattern; |
52 | 53 | import dev.cel.runtime.CelEvaluationException; |
53 | 54 | import dev.cel.runtime.CelFunctionBinding; |
54 | 55 | import dev.cel.runtime.CelRuntime; |
55 | 56 | import dev.cel.runtime.InterpreterUtil; |
| 57 | +import dev.cel.runtime.PartialVars; |
56 | 58 | import java.time.Duration; |
57 | 59 | import java.time.Instant; |
58 | 60 | import java.util.List; |
@@ -897,14 +899,12 @@ public void optionalIndex_onMap_returnsOptionalValue() throws Exception { |
897 | 899 | @TestParameters("{source: '{?x: x}'}") |
898 | 900 | public void optionalIndex_onMapWithUnknownInput_returnsUnknownResult(String source) |
899 | 901 | throws Exception { |
900 | | - if (testMode.equals(TestMode.PLANNER_CHECKED) || testMode.equals(TestMode.PLANNER_PARSE_ONLY)) { |
901 | | - // TODO: Uncomment once unknowns is implemented |
902 | | - return; |
903 | | - } |
904 | 902 | Cel cel = newCelBuilder().addVar("x", OptionalType.create(SimpleType.INT)).build(); |
905 | 903 | CelAbstractSyntaxTree ast = compile(cel, source); |
906 | 904 |
|
907 | | - Object result = cel.createProgram(ast).eval(); |
| 905 | + Object result = |
| 906 | + cel.createProgram(ast) |
| 907 | + .eval(PartialVars.of(CelAttributePattern.fromQualifiedIdentifier("x"))); |
908 | 908 |
|
909 | 909 | assertThat(InterpreterUtil.isUnknown(result)).isTrue(); |
910 | 910 | } |
@@ -987,18 +987,16 @@ public void optionalIndex_onOptionalList_returnsOptionalValue() throws Exception |
987 | 987 |
|
988 | 988 | @Test |
989 | 989 | public void optionalIndex_onListWithUnknownInput_returnsUnknownResult() throws Exception { |
990 | | - if (testMode.equals(TestMode.PLANNER_CHECKED) || testMode.equals(TestMode.PLANNER_PARSE_ONLY)) { |
991 | | - // TODO: Uncomment once unknowns is implemented |
992 | | - return; |
993 | | - } |
994 | 990 | Cel cel = |
995 | 991 | newCelBuilder() |
996 | 992 | .addVar("x", OptionalType.create(SimpleType.INT)) |
997 | 993 | .setResultType(ListType.create(SimpleType.INT)) |
998 | 994 | .build(); |
999 | 995 | CelAbstractSyntaxTree ast = compile(cel, "[?x]"); |
1000 | 996 |
|
1001 | | - Object result = cel.createProgram(ast).eval(); |
| 997 | + Object result = |
| 998 | + cel.createProgram(ast) |
| 999 | + .eval(PartialVars.of(CelAttributePattern.fromQualifiedIdentifier("x"))); |
1002 | 1000 |
|
1003 | 1001 | assertThat(InterpreterUtil.isUnknown(result)).isTrue(); |
1004 | 1002 | } |
@@ -1026,18 +1024,16 @@ public void traditionalIndex_onOptionalList_returnsOptionalEmpty() throws Except |
1026 | 1024 | @TestParameters("{expression: 'optional.none().orValue(optx)'}") |
1027 | 1025 | public void optionalChainedFunctions_lhsIsUnknown_returnsUnknown(String expression) |
1028 | 1026 | throws Exception { |
1029 | | - if (testMode.equals(TestMode.PLANNER_CHECKED) || testMode.equals(TestMode.PLANNER_PARSE_ONLY)) { |
1030 | | - // TODO: Uncomment once unknowns is implemented |
1031 | | - return; |
1032 | | - } |
1033 | 1027 | Cel cel = |
1034 | 1028 | newCelBuilder() |
1035 | 1029 | .addVar("optx", OptionalType.create(SimpleType.INT)) |
1036 | 1030 | .addVar("x", SimpleType.INT) |
1037 | 1031 | .build(); |
1038 | 1032 | CelAbstractSyntaxTree ast = compile(cel, expression); |
1039 | 1033 |
|
1040 | | - Object result = cel.createProgram(ast).eval(); |
| 1034 | + Object result = |
| 1035 | + cel.createProgram(ast) |
| 1036 | + .eval(PartialVars.of(CelAttributePattern.fromQualifiedIdentifier("optx"))); |
1041 | 1037 |
|
1042 | 1038 | assertThat(InterpreterUtil.isUnknown(result)).isTrue(); |
1043 | 1039 | } |
|
0 commit comments