Skip to content

Commit 73eb5f9

Browse files
jnthntatumcopybara-github
authored andcommitted
Opt tests into updated accumulator variable ahead of default enabling.
PiperOrigin-RevId: 709846512
1 parent ece46c4 commit 73eb5f9

File tree

12 files changed

+213
-199
lines changed

12 files changed

+213
-199
lines changed

checker/src/test/resources/mapExpr.baseline

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ __comprehension__(
99
// Target
1010
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
1111
// Accumulator
12-
__result__,
12+
@result,
1313
// Init
1414
[]~list(double),
1515
// LoopCondition
1616
true~bool,
1717
// LoopStep
1818
_+_(
19-
__result__~list(double)^__result__,
19+
@result~list(double)^@result,
2020
[
2121
double(
2222
x~int^x
2323
)~double^int64_to_double
2424
]~list(double)
2525
)~list(double)^add_list,
2626
// Result
27-
__result__~list(double)^__result__)~list(double)
27+
@result~list(double)^@result)~list(double)
2828

2929
Source: [].map(x, [].map(y, x in y && y in x))
3030
declare x {
3131
value cel.expr.conformance.proto3.TestAllTypes
3232
}
3333
=====>
3434
ERROR: test_location:1:33: found no matching overload for '@in' applied to '(list(%elem0), %elem0)' (candidates: (%A7, list(%A7)),(%A8, map(%A8, %B9)))
35-
| [].map(x, [].map(y, x in y && y in x))
36-
| ................................^
35+
| [].map(x, [].map(y, x in y && y in x))
36+
| ................................^
3737

3838
Source: [{}.map(c,c,c)]+[{}.map(c,c,c)]
3939
declare x {
@@ -48,7 +48,7 @@ _+_(
4848
// Target
4949
{}~map(bool, dyn),
5050
// Accumulator
51-
__result__,
51+
@result,
5252
// Init
5353
[]~list(bool),
5454
// LoopCondition
@@ -57,15 +57,15 @@ _+_(
5757
_?_:_(
5858
c~bool^c,
5959
_+_(
60-
__result__~list(bool)^__result__,
60+
@result~list(bool)^@result,
6161
[
6262
c~bool^c
6363
]~list(bool)
6464
)~list(bool)^add_list,
65-
__result__~list(bool)^__result__
65+
@result~list(bool)^@result
6666
)~list(bool)^conditional,
6767
// Result
68-
__result__~list(bool)^__result__)~list(bool)
68+
@result~list(bool)^@result)~list(bool)
6969
]~list(list(bool)),
7070
[
7171
__comprehension__(
@@ -74,7 +74,7 @@ _+_(
7474
// Target
7575
{}~map(bool, dyn),
7676
// Accumulator
77-
__result__,
77+
@result,
7878
// Init
7979
[]~list(bool),
8080
// LoopCondition
@@ -83,14 +83,14 @@ _+_(
8383
_?_:_(
8484
c~bool^c,
8585
_+_(
86-
__result__~list(bool)^__result__,
86+
@result~list(bool)^@result,
8787
[
8888
c~bool^c
8989
]~list(bool)
9090
)~list(bool)^add_list,
91-
__result__~list(bool)^__result__
91+
@result~list(bool)^@result
9292
)~list(bool)^conditional,
9393
// Result
94-
__result__~list(bool)^__result__)~list(bool)
94+
@result~list(bool)^@result)~list(bool)
9595
]~list(list(bool))
96-
)~list(list(bool))^add_list
96+
)~list(list(bool))^add_list

checker/src/test/resources/mapFilterExpr.baseline

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ __comprehension__(
99
// Target
1010
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
1111
// Accumulator
12-
__result__,
12+
@result,
1313
// Init
1414
[]~list(double),
1515
// LoopCondition
@@ -21,17 +21,17 @@ __comprehension__(
2121
0~int
2222
)~bool^greater_int64,
2323
_+_(
24-
__result__~list(double)^__result__,
24+
@result~list(double)^@result,
2525
[
2626
double(
2727
x~int^x
2828
)~double^int64_to_double
2929
]~list(double)
3030
)~list(double)^add_list,
31-
__result__~list(double)^__result__
31+
@result~list(double)^@result
3232
)~list(double)^conditional,
3333
// Result
34-
__result__~list(double)^__result__)~list(double)
34+
@result~list(double)^@result)~list(double)
3535

3636
Source: lists.filter(x, x > 1.5)
3737
declare x {
@@ -47,7 +47,7 @@ __comprehension__(
4747
// Target
4848
lists~dyn^lists,
4949
// Accumulator
50-
__result__,
50+
@result,
5151
// Init
5252
[]~list(dyn),
5353
// LoopCondition
@@ -59,15 +59,15 @@ __comprehension__(
5959
1.5~double
6060
)~bool^greater_double|greater_int64_double|greater_uint64_double,
6161
_+_(
62-
__result__~list(dyn)^__result__,
62+
@result~list(dyn)^@result,
6363
[
6464
x~dyn^x
6565
]~list(dyn)
6666
)~list(dyn)^add_list,
67-
__result__~list(dyn)^__result__
67+
@result~list(dyn)^@result
6868
)~list(dyn)^conditional,
6969
// Result
70-
__result__~list(dyn)^__result__)~list(dyn)
70+
@result~list(dyn)^@result)~list(dyn)
7171

7272
Source: args.user["myextension"].customAttributes.filter(x, x.name == "hobbies")
7373
declare x {
@@ -89,7 +89,7 @@ __comprehension__(
8989
"myextension"~string
9090
)~dyn^index_map.customAttributes~dyn,
9191
// Accumulator
92-
__result__,
92+
@result,
9393
// Init
9494
[]~list(dyn),
9595
// LoopCondition
@@ -101,12 +101,12 @@ __comprehension__(
101101
"hobbies"~string
102102
)~bool^equals,
103103
_+_(
104-
__result__~list(dyn)^__result__,
104+
@result~list(dyn)^@result,
105105
[
106106
x~dyn^x
107107
]~list(dyn)
108108
)~list(dyn)^add_list,
109-
__result__~list(dyn)^__result__
109+
@result~list(dyn)^@result
110110
)~list(dyn)^conditional,
111111
// Result
112-
__result__~list(dyn)^__result__)~list(dyn)
112+
@result~list(dyn)^@result)~list(dyn)

checker/src/test/resources/namespacedFunctions.baseline

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ __comprehension__(
8484
)~int^ns_func_overload
8585
]~list(int),
8686
// Accumulator
87-
__result__,
87+
@result,
8888
// Init
8989
[]~list(int),
9090
// LoopCondition
9191
true~bool,
9292
// LoopStep
9393
_+_(
94-
__result__~list(int)^__result__,
94+
@result~list(int)^@result,
9595
[
9696
_*_(
9797
x~int^x,
@@ -100,7 +100,7 @@ __comprehension__(
100100
]~list(int)
101101
)~list(int)^add_list,
102102
// Result
103-
__result__~list(int)^__result__)~list(int)
103+
@result~list(int)^@result)~list(int)
104104

105105
Source: [1, 2].map(x, x * ns.func('test'))
106106
declare ns.func {
@@ -119,14 +119,14 @@ __comprehension__(
119119
2~int
120120
]~list(int),
121121
// Accumulator
122-
__result__,
122+
@result,
123123
// Init
124124
[]~list(int),
125125
// LoopCondition
126126
true~bool,
127127
// LoopStep
128128
_+_(
129-
__result__~list(int)^__result__,
129+
@result~list(int)^@result,
130130
[
131131
_*_(
132132
x~int^x,
@@ -137,7 +137,7 @@ __comprehension__(
137137
]~list(int)
138138
)~list(int)^add_list,
139139
// Result
140-
__result__~list(int)^__result__)~list(int)
140+
@result~list(int)^@result)~list(int)
141141

142142
Source: func('hello')
143143
declare ns.func {
@@ -165,4 +165,4 @@ ns.func(
165165
ns.func(
166166
"test"~string
167167
)~int^ns_func_overload
168-
)~int^ns_member_overload
168+
)~int^ns_member_overload

checker/src/test/resources/quantifiers.baseline

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,56 @@ _&&_(
1111
// Target
1212
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
1313
// Accumulator
14-
__result__,
14+
@result,
1515
// Init
1616
true~bool,
1717
// LoopCondition
1818
@not_strictly_false(
19-
__result__~bool^__result__
19+
@result~bool^@result
2020
)~bool^not_strictly_false,
2121
// LoopStep
2222
_&&_(
23-
__result__~bool^__result__,
23+
@result~bool^@result,
2424
_>_(
2525
e~int^e,
2626
0~int
2727
)~bool^greater_int64
2828
)~bool^logical_and,
2929
// Result
30-
__result__~bool^__result__)~bool,
30+
@result~bool^@result)~bool,
3131
__comprehension__(
3232
// Variable
3333
e,
3434
// Target
3535
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
3636
// Accumulator
37-
__result__,
37+
@result,
3838
// Init
3939
false~bool,
4040
// LoopCondition
4141
@not_strictly_false(
4242
!_(
43-
__result__~bool^__result__
43+
@result~bool^@result
4444
)~bool^logical_not
4545
)~bool^not_strictly_false,
4646
// LoopStep
4747
_||_(
48-
__result__~bool^__result__,
48+
@result~bool^@result,
4949
_<_(
5050
e~int^e,
5151
0~int
5252
)~bool^less_int64
5353
)~bool^logical_or,
5454
// Result
55-
__result__~bool^__result__)~bool
55+
@result~bool^@result)~bool
5656
)~bool^logical_and,
5757
__comprehension__(
5858
// Variable
5959
e,
6060
// Target
6161
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
6262
// Accumulator
63-
__result__,
63+
@result,
6464
// Init
6565
0~int,
6666
// LoopCondition
@@ -72,14 +72,14 @@ _&&_(
7272
0~int
7373
)~bool^equals,
7474
_+_(
75-
__result__~int^__result__,
75+
@result~int^@result,
7676
1~int
7777
)~int^add_int64,
78-
__result__~int^__result__
78+
@result~int^@result
7979
)~int^conditional,
8080
// Result
8181
_==_(
82-
__result__~int^__result__,
82+
@result~int^@result,
8383
1~int
8484
)~bool^equals)~bool
85-
)~bool^logical_and
85+
)~bool^logical_and

checker/src/test/resources/types.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ __comprehension__(
2727
// Target
2828
{}~map(dyn, dyn),
2929
// Accumulator
30-
__result__,
30+
@result,
3131
// Init
3232
[]~list(list(dyn)),
3333
// LoopCondition
3434
true~bool,
3535
// LoopStep
3636
_+_(
37-
__result__~list(list(dyn))^__result__,
37+
@result~list(list(dyn))^@result,
3838
[
3939
[
4040
c~dyn^c,
@@ -45,4 +45,4 @@ __comprehension__(
4545
]~list(list(dyn))
4646
)~list(list(dyn))^add_list,
4747
// Result
48-
__result__~list(list(dyn))^__result__)~list(list(dyn))
48+
@result~list(list(dyn))^@result)~list(list(dyn))

common/src/test/java/dev/cel/common/ast/CelExprFormatterTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
2121
import dev.cel.common.CelAbstractSyntaxTree;
2222
import dev.cel.common.CelFunctionDecl;
23+
import dev.cel.common.CelOptions;
2324
import dev.cel.common.CelOverloadDecl;
2425
import dev.cel.common.types.SimpleType;
2526
import dev.cel.common.types.StructTypeReference;
@@ -272,6 +273,7 @@ public void map() throws Exception {
272273
public void comprehension() throws Exception {
273274
CelCompiler celCompiler =
274275
CelCompilerFactory.standardCelCompilerBuilder()
276+
.setOptions(CelOptions.current().enableHiddenAccumulatorVar(true).build())
275277
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
276278
.build();
277279
CelAbstractSyntaxTree ast = celCompiler.compile("[1, 2, 3].exists(x, x > 0)").getAst();
@@ -291,7 +293,7 @@ public void comprehension() throws Exception {
291293
+ " }\n"
292294
+ " }\n"
293295
+ " }\n"
294-
+ " accu_var: __result__\n"
296+
+ " accu_var: @result\n"
295297
+ " accu_init: {\n"
296298
+ " CONSTANT [10] { value: false }\n"
297299
+ " }\n"
@@ -303,7 +305,7 @@ public void comprehension() throws Exception {
303305
+ " function: !_\n"
304306
+ " args: {\n"
305307
+ " IDENT [11] {\n"
306-
+ " name: __result__\n"
308+
+ " name: @result\n"
307309
+ " }\n"
308310
+ " }\n"
309311
+ " }\n"
@@ -315,7 +317,7 @@ public void comprehension() throws Exception {
315317
+ " function: _||_\n"
316318
+ " args: {\n"
317319
+ " IDENT [14] {\n"
318-
+ " name: __result__\n"
320+
+ " name: @result\n"
319321
+ " }\n"
320322
+ " CALL [8] {\n"
321323
+ " function: _>_\n"
@@ -331,7 +333,7 @@ public void comprehension() throws Exception {
331333
+ " }\n"
332334
+ " result: {\n"
333335
+ " IDENT [16] {\n"
334-
+ " name: __result__\n"
336+
+ " name: @result\n"
335337
+ " }\n"
336338
+ " }\n"
337339
+ "}");

0 commit comments

Comments
 (0)