@@ -38,7 +38,7 @@ func TestConfig(t *testing.T) {
3838 want * Config
3939 }{
4040 {
41- name : "context_env" ,
41+ name : "context_env.yaml " ,
4242 want : NewConfig ("context-env" ).
4343 SetContainer ("google.expr" ).
4444 AddImports (NewImport ("google.expr.proto3.test.TestAllTypes" )).
@@ -75,7 +75,7 @@ func TestConfig(t *testing.T) {
7575 ),
7676 },
7777 {
78- name : "extended_env" ,
78+ name : "extended_env.yaml " ,
7979 want : NewConfig ("extended-env" ).
8080 SetContainer ("google.expr" ).
8181 AddExtensions (
@@ -107,7 +107,7 @@ func TestConfig(t *testing.T) {
107107 `determines whether a list is empty,` ,
108108 `or a string has no characters` ),
109109 NewMemberOverload ("wrapper_string_isEmpty" ,
110- NewTypeDesc ("google.protobuf.StringValue " ), nil ,
110+ NewTypeDesc ("string_wrapper " ), nil ,
111111 NewTypeDesc ("bool" ),
112112 `''.isEmptyAlt() // true` ),
113113 NewMemberOverload ("list_isEmpty" ,
@@ -141,7 +141,60 @@ func TestConfig(t *testing.T) {
141141 ),
142142 },
143143 {
144- name : "subset_env" ,
144+ name : "json_env.json" ,
145+ want : NewConfig ("extended-env" ).
146+ SetContainer ("google.expr" ).
147+ AddExtensions (
148+ NewExtension ("optional" , 2 ),
149+ NewExtension ("math" , math .MaxUint32 ),
150+ ).AddVariables (
151+ NewVariableWithDoc ("msg" ,
152+ NewTypeDesc ("google.expr.proto3.test.TestAllTypes" ),
153+ `msg represents all possible type permutation which CEL understands from a proto perspective` ),
154+ NewVariableWithDoc ("opt_msg" ,
155+ NewTypeDesc ("optional_type" , NewTypeDesc ("google.expr.proto3.test.TestAllTypes" )),
156+ `opt_msg represents all possible type permutation which CEL understands from a proto perspective` ),
157+ ).AddFunctions (
158+ NewFunctionWithDoc ("isEmpty" ,
159+ common .MultilineDescription (
160+ `determines whether a list is empty,` ,
161+ `or a string has no characters` ),
162+ NewMemberOverload ("wrapper_string_isEmpty" ,
163+ NewTypeDesc ("wrapper_string" ), nil ,
164+ NewTypeDesc ("bool" ),
165+ `''.isEmpty() // true` ),
166+ NewMemberOverload ("list_isEmpty" ,
167+ NewTypeDesc ("list" , NewTypeParam ("T" )), nil ,
168+ NewTypeDesc ("bool" ),
169+ `[].isEmpty() // true` ,
170+ `[1].isEmpty() // false` )),
171+ NewFunctionWithDoc (
172+ "getOrDefault" ,
173+ common .MultilineDescription (
174+ "Returns the value of a key in a map or the provided" ,
175+ "default value." ),
176+ NewMemberOverload ("map_getOrDefault" ,
177+ NewTypeDesc ("map" , NewTypeParam ("K" ), NewTypeParam ("V" )),
178+ []* TypeDesc {
179+ NewTypeParam ("K" ),
180+ NewTypeParam ("V" ),
181+ },
182+ NewTypeParam ("V" ),
183+ )),
184+ ).AddFeatures (
185+ NewFeature ("cel.feature.macro_call_tracking" , true ),
186+ ).AddLimits (
187+ NewLimit ("cel.limit.parse_recursion_depth" , 7 ),
188+ ).AddValidators (
189+ NewValidator ("cel.validator.duration" ),
190+ NewValidator ("cel.validator.matches" ),
191+ NewValidator ("cel.validator.timestamp" ),
192+ NewValidator ("cel.validator.comprehension_nesting_limit" ).
193+ SetConfig (map [string ]any {"limit" : 2 }),
194+ ),
195+ },
196+ {
197+ name : "subset_env.yaml" ,
145198 want : NewConfig ("subset-env" ).
146199 SetStdLib (NewLibrarySubset ().
147200 AddExcludedMacros ("map" , "filter" ).
@@ -170,7 +223,7 @@ func TestConfig(t *testing.T) {
170223 for _ , tst := range tests {
171224 tc := tst
172225 t .Run (tc .name , func (t * testing.T ) {
173- fileName := fmt .Sprintf ("testdata/%s.yaml " , tc .name )
226+ fileName := fmt .Sprintf ("testdata/%s" , tc .name )
174227 data , err := os .ReadFile (fileName )
175228 if err != nil {
176229 t .Fatalf ("os.ReadFile(%q) failed: %v" , fileName , err )
@@ -685,6 +738,14 @@ func TestVariableAsCELVariable(t *testing.T) {
685738 },
686739 want : decls .NewVariable ("msg" , types .NewNullableType (types .StringType )),
687740 },
741+ {
742+ name : "wrapper type alias variable" ,
743+ v : & Variable {
744+ Name : "msg" ,
745+ TypeDesc : NewTypeDesc ("string_wrapper" ),
746+ },
747+ want : decls .NewVariable ("msg" , types .NewNullableType (types .StringType )),
748+ },
688749 }
689750
690751 tp , err := types .NewProtoRegistry ()
0 commit comments