Skip to content

Commit

Permalink
Opt tests into updated accumulator variable ahead of default enabling.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 709846512
  • Loading branch information
jnthntatum authored and copybara-github committed Dec 26, 2024
1 parent ece46c4 commit 73eb5f9
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 199 deletions.
28 changes: 14 additions & 14 deletions checker/src/test/resources/mapExpr.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ __comprehension__(
// Target
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
// Accumulator
__result__,
@result,
// Init
[]~list(double),
// LoopCondition
true~bool,
// LoopStep
_+_(
__result__~list(double)^__result__,
@result~list(double)^@result,
[
double(
x~int^x
)~double^int64_to_double
]~list(double)
)~list(double)^add_list,
// Result
__result__~list(double)^__result__)~list(double)
@result~list(double)^@result)~list(double)

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

Source: [{}.map(c,c,c)]+[{}.map(c,c,c)]
declare x {
Expand All @@ -48,7 +48,7 @@ _+_(
// Target
{}~map(bool, dyn),
// Accumulator
__result__,
@result,
// Init
[]~list(bool),
// LoopCondition
Expand All @@ -57,15 +57,15 @@ _+_(
_?_:_(
c~bool^c,
_+_(
__result__~list(bool)^__result__,
@result~list(bool)^@result,
[
c~bool^c
]~list(bool)
)~list(bool)^add_list,
__result__~list(bool)^__result__
@result~list(bool)^@result
)~list(bool)^conditional,
// Result
__result__~list(bool)^__result__)~list(bool)
@result~list(bool)^@result)~list(bool)
]~list(list(bool)),
[
__comprehension__(
Expand All @@ -74,7 +74,7 @@ _+_(
// Target
{}~map(bool, dyn),
// Accumulator
__result__,
@result,
// Init
[]~list(bool),
// LoopCondition
Expand All @@ -83,14 +83,14 @@ _+_(
_?_:_(
c~bool^c,
_+_(
__result__~list(bool)^__result__,
@result~list(bool)^@result,
[
c~bool^c
]~list(bool)
)~list(bool)^add_list,
__result__~list(bool)^__result__
@result~list(bool)^@result
)~list(bool)^conditional,
// Result
__result__~list(bool)^__result__)~list(bool)
@result~list(bool)^@result)~list(bool)
]~list(list(bool))
)~list(list(bool))^add_list
)~list(list(bool))^add_list
24 changes: 12 additions & 12 deletions checker/src/test/resources/mapFilterExpr.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __comprehension__(
// Target
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
// Accumulator
__result__,
@result,
// Init
[]~list(double),
// LoopCondition
Expand All @@ -21,17 +21,17 @@ __comprehension__(
0~int
)~bool^greater_int64,
_+_(
__result__~list(double)^__result__,
@result~list(double)^@result,
[
double(
x~int^x
)~double^int64_to_double
]~list(double)
)~list(double)^add_list,
__result__~list(double)^__result__
@result~list(double)^@result
)~list(double)^conditional,
// Result
__result__~list(double)^__result__)~list(double)
@result~list(double)^@result)~list(double)

Source: lists.filter(x, x > 1.5)
declare x {
Expand All @@ -47,7 +47,7 @@ __comprehension__(
// Target
lists~dyn^lists,
// Accumulator
__result__,
@result,
// Init
[]~list(dyn),
// LoopCondition
Expand All @@ -59,15 +59,15 @@ __comprehension__(
1.5~double
)~bool^greater_double|greater_int64_double|greater_uint64_double,
_+_(
__result__~list(dyn)^__result__,
@result~list(dyn)^@result,
[
x~dyn^x
]~list(dyn)
)~list(dyn)^add_list,
__result__~list(dyn)^__result__
@result~list(dyn)^@result
)~list(dyn)^conditional,
// Result
__result__~list(dyn)^__result__)~list(dyn)
@result~list(dyn)^@result)~list(dyn)

Source: args.user["myextension"].customAttributes.filter(x, x.name == "hobbies")
declare x {
Expand All @@ -89,7 +89,7 @@ __comprehension__(
"myextension"~string
)~dyn^index_map.customAttributes~dyn,
// Accumulator
__result__,
@result,
// Init
[]~list(dyn),
// LoopCondition
Expand All @@ -101,12 +101,12 @@ __comprehension__(
"hobbies"~string
)~bool^equals,
_+_(
__result__~list(dyn)^__result__,
@result~list(dyn)^@result,
[
x~dyn^x
]~list(dyn)
)~list(dyn)^add_list,
__result__~list(dyn)^__result__
@result~list(dyn)^@result
)~list(dyn)^conditional,
// Result
__result__~list(dyn)^__result__)~list(dyn)
@result~list(dyn)^@result)~list(dyn)
14 changes: 7 additions & 7 deletions checker/src/test/resources/namespacedFunctions.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ __comprehension__(
)~int^ns_func_overload
]~list(int),
// Accumulator
__result__,
@result,
// Init
[]~list(int),
// LoopCondition
true~bool,
// LoopStep
_+_(
__result__~list(int)^__result__,
@result~list(int)^@result,
[
_*_(
x~int^x,
Expand All @@ -100,7 +100,7 @@ __comprehension__(
]~list(int)
)~list(int)^add_list,
// Result
__result__~list(int)^__result__)~list(int)
@result~list(int)^@result)~list(int)

Source: [1, 2].map(x, x * ns.func('test'))
declare ns.func {
Expand All @@ -119,14 +119,14 @@ __comprehension__(
2~int
]~list(int),
// Accumulator
__result__,
@result,
// Init
[]~list(int),
// LoopCondition
true~bool,
// LoopStep
_+_(
__result__~list(int)^__result__,
@result~list(int)^@result,
[
_*_(
x~int^x,
Expand All @@ -137,7 +137,7 @@ __comprehension__(
]~list(int)
)~list(int)^add_list,
// Result
__result__~list(int)^__result__)~list(int)
@result~list(int)^@result)~list(int)

Source: func('hello')
declare ns.func {
Expand Down Expand Up @@ -165,4 +165,4 @@ ns.func(
ns.func(
"test"~string
)~int^ns_func_overload
)~int^ns_member_overload
)~int^ns_member_overload
26 changes: 13 additions & 13 deletions checker/src/test/resources/quantifiers.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,56 @@ _&&_(
// Target
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
// Accumulator
__result__,
@result,
// Init
true~bool,
// LoopCondition
@not_strictly_false(
__result__~bool^__result__
@result~bool^@result
)~bool^not_strictly_false,
// LoopStep
_&&_(
__result__~bool^__result__,
@result~bool^@result,
_>_(
e~int^e,
0~int
)~bool^greater_int64
)~bool^logical_and,
// Result
__result__~bool^__result__)~bool,
@result~bool^@result)~bool,
__comprehension__(
// Variable
e,
// Target
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
// Accumulator
__result__,
@result,
// Init
false~bool,
// LoopCondition
@not_strictly_false(
!_(
__result__~bool^__result__
@result~bool^@result
)~bool^logical_not
)~bool^not_strictly_false,
// LoopStep
_||_(
__result__~bool^__result__,
@result~bool^@result,
_<_(
e~int^e,
0~int
)~bool^less_int64
)~bool^logical_or,
// Result
__result__~bool^__result__)~bool
@result~bool^@result)~bool
)~bool^logical_and,
__comprehension__(
// Variable
e,
// Target
x~cel.expr.conformance.proto3.TestAllTypes^x.repeated_int64~list(int),
// Accumulator
__result__,
@result,
// Init
0~int,
// LoopCondition
Expand All @@ -72,14 +72,14 @@ _&&_(
0~int
)~bool^equals,
_+_(
__result__~int^__result__,
@result~int^@result,
1~int
)~int^add_int64,
__result__~int^__result__
@result~int^@result
)~int^conditional,
// Result
_==_(
__result__~int^__result__,
@result~int^@result,
1~int
)~bool^equals)~bool
)~bool^logical_and
)~bool^logical_and
6 changes: 3 additions & 3 deletions checker/src/test/resources/types.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ __comprehension__(
// Target
{}~map(dyn, dyn),
// Accumulator
__result__,
@result,
// Init
[]~list(list(dyn)),
// LoopCondition
true~bool,
// LoopStep
_+_(
__result__~list(list(dyn))^__result__,
@result~list(list(dyn))^@result,
[
[
c~dyn^c,
Expand All @@ -45,4 +45,4 @@ __comprehension__(
]~list(list(dyn))
)~list(list(dyn))^add_list,
// Result
__result__~list(list(dyn))^__result__)~list(list(dyn))
@result~list(list(dyn))^@result)~list(list(dyn))
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelOverloadDecl;
import dev.cel.common.types.SimpleType;
import dev.cel.common.types.StructTypeReference;
Expand Down Expand Up @@ -272,6 +273,7 @@ public void map() throws Exception {
public void comprehension() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setOptions(CelOptions.current().enableHiddenAccumulatorVar(true).build())
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
.build();
CelAbstractSyntaxTree ast = celCompiler.compile("[1, 2, 3].exists(x, x > 0)").getAst();
Expand All @@ -291,7 +293,7 @@ public void comprehension() throws Exception {
+ " }\n"
+ " }\n"
+ " }\n"
+ " accu_var: __result__\n"
+ " accu_var: @result\n"
+ " accu_init: {\n"
+ " CONSTANT [10] { value: false }\n"
+ " }\n"
Expand All @@ -303,7 +305,7 @@ public void comprehension() throws Exception {
+ " function: !_\n"
+ " args: {\n"
+ " IDENT [11] {\n"
+ " name: __result__\n"
+ " name: @result\n"
+ " }\n"
+ " }\n"
+ " }\n"
Expand All @@ -315,7 +317,7 @@ public void comprehension() throws Exception {
+ " function: _||_\n"
+ " args: {\n"
+ " IDENT [14] {\n"
+ " name: __result__\n"
+ " name: @result\n"
+ " }\n"
+ " CALL [8] {\n"
+ " function: _>_\n"
Expand All @@ -331,7 +333,7 @@ public void comprehension() throws Exception {
+ " }\n"
+ " result: {\n"
+ " IDENT [16] {\n"
+ " name: __result__\n"
+ " name: @result\n"
+ " }\n"
+ " }\n"
+ "}");
Expand Down
Loading

0 comments on commit 73eb5f9

Please sign in to comment.