@@ -115,18 +115,21 @@ public final class CelVerifierZ3ImplTest {
115115 .addVar (
116116 "test_all_types" ,
117117 StructTypeReference .create ("cel.expr.conformance.proto3.TestAllTypes" ))
118+ .addVar ("json_val" , StructTypeReference .create ("google.protobuf.Value" ))
119+ .addVar ("json_list" , StructTypeReference .create ("google.protobuf.ListValue" ))
120+ .addVar ("json_struct" , StructTypeReference .create ("google.protobuf.Struct" ))
118121 .build ();
119122
120- private static final CelVerifier VERIFIER =
121- CelVerifierFactory .newVerifier ()
122- .setTypeProvider (
123- ProtoMessageTypeProvider .newBuilder ()
124- .addDescriptors (
125- ImmutableList .of (
126- TestAllTypes .getDescriptor (), TestAllTypes .NestedMessage .getDescriptor ()))
127- .build ())
123+ private static final ProtoMessageTypeProvider TYPE_PROVIDER =
124+ ProtoMessageTypeProvider .newBuilder ()
125+ .addDescriptors (
126+ ImmutableList .of (
127+ TestAllTypes .getDescriptor (), TestAllTypes .NestedMessage .getDescriptor ()))
128128 .build ();
129129
130+ private static final CelVerifier VERIFIER =
131+ CelVerifierFactory .newVerifier ().setTypeProvider (TYPE_PROVIDER ).build ();
132+
130133 @ Before
131134 public void setUp () {
132135 System .setProperty ("z3.skipLibraryLoad" , "true" );
@@ -226,9 +229,6 @@ private enum IsSatisfiableInconclusiveTestCase {
226229 MASKED_BY_BMC_MAP (
227230 "string_int_map == {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6} ? string_int_map.exists(k,"
228231 + " k == 'g') : false" ),
229- MASKED_BY_BMC_NESTED (
230- "nested_list == [[1, 2, 3, 4, 5, 6]] ? nested_list.exists(row, row.exists(x, x == 42)) :"
231- + " false" ),
232232 APPROXIMATED_STRING_TO_INT ("int('123') == 123" ),
233233 APPROXIMATED_DOUBLE_TO_INT ("int(1.5) == 1" ),
234234 APPROXIMATED_INT_TO_STRING ("string(123) == '123'" ),
@@ -252,6 +252,24 @@ public void isSatisfiable_inconclusive(@TestParameter IsSatisfiableInconclusiveT
252252 assertThat (result .status ()).isEqualTo (VerificationStatus .INCONCLUSIVE );
253253 }
254254
255+ @ Test
256+ public void isSatisfiable_maskedByBmcNested_inconclusive () throws Exception {
257+ String expr =
258+ "nested_list == [[1, 2, 3, 4, 5, 6]] ? nested_list.exists(row, row.exists(x, x == 42)) :"
259+ + " false" ;
260+ CelAbstractSyntaxTree ast = CEL .compile (expr ).getAst ();
261+
262+ CelVerifier customVerifier =
263+ CelVerifierFactory .newVerifier ()
264+ .setComprehensionUnrollLimit (3 )
265+ .setTypeProvider (TYPE_PROVIDER )
266+ .build ();
267+
268+ CelVerificationResult result = customVerifier .isSatisfiable (ast );
269+
270+ assertThat (result .status ()).isEqualTo (VerificationStatus .INCONCLUSIVE );
271+ }
272+
255273 @ Test
256274 public void isSatisfiable_comprehensionZeroUnrollLimit_inconclusive () throws Exception {
257275 String expr = "int_list == [1] ? int_list.exists(x, x == 1) : false" ;
@@ -1590,7 +1608,34 @@ private enum EquivalenceTestCase {
15901608 "true" ),
15911609 OPTIONAL_FIELD_SELECTION_MAP_COMPREHENSION (
15921610 "{'a': 1, 'b': 2}.transformMap(k, v, v > 1, v).?b" , "optional.of(2)" ),
1593- OPTIONAL_FIELD_SELECTION_BINDER ("cel.bind(m, {'a': 1}, m.?a)" , "optional.of(1)" );
1611+ OPTIONAL_FIELD_SELECTION_BINDER ("cel.bind(m, {'a': 1}, m.?a)" , "optional.of(1)" ),
1612+ JSON_VALUE_BOOL ("google.protobuf.Value{bool_value: true}" , "true" ),
1613+ JSON_VALUE_NUMBER ("google.protobuf.Value{number_value: 1.0}" , "1.0" ),
1614+ JSON_VALUE_NULL ("google.protobuf.Value{null_value: 0}" , "null" ),
1615+ JSON_VALUE_EMPTY ("google.protobuf.Value{}" , "null" ),
1616+ JSON_LIST_VALUE_EMPTY ("google.protobuf.ListValue{}" , "[]" ),
1617+ JSON_STRUCT_EMPTY ("google.protobuf.Struct{}" , "{}" ),
1618+ JSON_LIST_VALUE ("google.protobuf.ListValue{values: [1, 2]}" , "[1, 2]" ),
1619+ JSON_STRUCT ("google.protobuf.Struct{fields: {'a': 1}}" , "{'a': 1}" ),
1620+ JSON_DEEP_NESTING (
1621+ "google.protobuf.ListValue{values: [google.protobuf.Struct{fields: {'a':"
1622+ + " google.protobuf.Value{number_value: 1.0}}}]}" ,
1623+ "[{'a': 1.0}]" ),
1624+ JSON_NUMBER_HETEROGENEOUS_EQUALITY ("google.protobuf.Value{number_value: 1.0} == 1" , "true" ),
1625+ JSON_VALUE_OPTIONAL_NONE ("google.protobuf.Value{?string_value: optional.none()}" , "null" ),
1626+ JSON_LIST_VALUE_OPTIONAL_NONE ("google.protobuf.ListValue{?values: optional.none()}" , "[]" ),
1627+ JSON_STRUCT_OPTIONAL_NONE ("google.protobuf.Struct{?fields: optional.none()}" , "{}" ),
1628+ JSON_VALUE_TYPE_REFLECTION ("type(google.protobuf.Value{string_value: 'hi'}) == string" , "true" ),
1629+ JSON_STRUCT_TYPE_REFLECTION ("type(google.protobuf.Struct{fields: {'a': 1}}) == map" , "true" ),
1630+ JSON_VAR_VALUE_EQUALITY ("json_val == 'hi' || json_val != 'hi'" , "true" ),
1631+ JSON_VAR_LIST_EQUALITY ("json_list == [1, 2] || json_list != [1, 2]" , "true" ),
1632+ JSON_VAR_MAP_EQUALITY ("json_struct == {'a': 1} || json_struct != {'a': 1}" , "true" ),
1633+ JSON_VALUE_OPTIONAL_NULL_VALUE_NONE (
1634+ "google.protobuf.Value{?null_value: optional.none()}" , "null" ),
1635+ JSON_VALUE_OPTIONAL_NULL_VALUE_OF ("google.protobuf.Value{?null_value: optional.of(0)}" , "null" ),
1636+ OPTIONAL_INDEX_LIST_UNWRAPPING ("optional.of([1, 2, 3])[?0]" , "optional.of(1)" ),
1637+ OPTIONAL_INDEX_MAP_UNWRAPPING ("optional.of({'a': 1})[?'a']" , "optional.of(1)" ),
1638+ OPTIONAL_INDEX_UNWRAPPING_NONE ("optional.none()[?0]" , "optional.none()" );
15941639
15951640 private final String exprA ;
15961641 private final String exprB ;
@@ -1644,7 +1689,10 @@ private enum EquivalenceViolationTestCase {
16441689 "TestAllTypes{single_int32: 0}.?single_int32" , "optional.of(0)" ),
16451690 OPTIONAL_PROTO3_WRAPPER_ZERO_VS_UNSET (
16461691 "TestAllTypes{single_int64_wrapper: 0}.?single_int64_wrapper" ,
1647- "TestAllTypes{}.?single_int64_wrapper" );
1692+ "TestAllTypes{}.?single_int64_wrapper" ),
1693+ OPTIONAL_DYNAMIC_TARGET_TYPE_MISMATCH ("dyn_var.?a == optional.none()" , "false" ),
1694+ OPTIONAL_NESTED_NONE_VS_MISSING (
1695+ "{'a': optional.none()}.?a.orValue(optional.of(1))" , "optional.of(1)" );
16481696
16491697 final String exprA ;
16501698 final String exprB ;
0 commit comments