3535import dev .cel .common .CelValidationResult ;
3636import dev .cel .common .types .CelProtoTypes ;
3737import dev .cel .compiler .CelCompilerFactory ;
38+ import dev .cel .compiler .CelCompilerLibrary ;
3839import dev .cel .expr .conformance .test .SimpleTest ;
3940import dev .cel .extensions .CelExtensions ;
4041import dev .cel .extensions .CelOptionalLibrary ;
4546import dev .cel .runtime .CelRuntime ;
4647import dev .cel .runtime .CelRuntime .Program ;
4748import dev .cel .runtime .CelRuntimeFactory ;
49+ import dev .cel .runtime .CelRuntimeLibrary ;
4850import java .util .Map ;
4951import org .junit .runners .model .Statement ;
5052
@@ -61,31 +63,37 @@ public final class ConformanceTest extends Statement {
6163 .enableQuotedIdentifierSyntax (true )
6264 .build ();
6365
66+ private static final ImmutableList <CelCompilerLibrary > CANONICAL_COMPILER_EXTENSIONS =
67+ ImmutableList .of (
68+ CelExtensions .bindings (),
69+ CelExtensions .comprehensions (),
70+ CelExtensions .encoders (OPTIONS ),
71+ CelExtensions .math (OPTIONS ),
72+ CelExtensions .protos (),
73+ CelExtensions .sets (OPTIONS ),
74+ CelExtensions .strings (),
75+ CelOptionalLibrary .INSTANCE );
76+
77+ private static final ImmutableList <CelRuntimeLibrary > CANONICAL_RUNTIME_EXTENSIONS =
78+ ImmutableList .of (
79+ CelExtensions .comprehensions (),
80+ CelExtensions .encoders (OPTIONS ),
81+ CelExtensions .math (OPTIONS ),
82+ CelExtensions .sets (OPTIONS ),
83+ CelExtensions .strings (),
84+ CelOptionalLibrary .INSTANCE );
85+
6486 private static final CelParser PARSER_WITH_MACROS =
6587 CelParserFactory .standardCelParserBuilder ()
6688 .setOptions (OPTIONS )
67- .addLibraries (
68- CelExtensions .bindings (),
69- CelExtensions .encoders (OPTIONS ),
70- CelExtensions .math (OPTIONS ),
71- CelExtensions .protos (),
72- CelExtensions .sets (OPTIONS ),
73- CelExtensions .strings (),
74- CelOptionalLibrary .INSTANCE )
89+ .addLibraries (CANONICAL_COMPILER_EXTENSIONS )
7590 .setStandardMacros (CelStandardMacro .STANDARD_MACROS )
7691 .build ();
7792
7893 private static final CelParser PARSER_WITHOUT_MACROS =
7994 CelParserFactory .standardCelParserBuilder ()
8095 .setOptions (OPTIONS )
81- .addLibraries (
82- CelExtensions .bindings (),
83- CelExtensions .encoders (OPTIONS ),
84- CelExtensions .math (OPTIONS ),
85- CelExtensions .protos (),
86- CelExtensions .sets (OPTIONS ),
87- CelExtensions .strings (),
88- CelOptionalLibrary .INSTANCE )
96+ .addLibraries (CANONICAL_COMPILER_EXTENSIONS )
8997 .setStandardMacros ()
9098 .build ();
9199
@@ -104,13 +112,7 @@ private static CelChecker getChecker(SimpleTest test) throws Exception {
104112 .setContainer (CelContainer .ofName (test .getContainer ()))
105113 .addDeclarations (decls .build ())
106114 .addFileTypes (dev .cel .expr .conformance .proto2 .TestAllTypesExtensions .getDescriptor ())
107- .addLibraries (
108- CelExtensions .bindings (),
109- CelExtensions .encoders (OPTIONS ),
110- CelExtensions .math (OPTIONS ),
111- CelExtensions .sets (OPTIONS ),
112- CelExtensions .strings (),
113- CelOptionalLibrary .INSTANCE )
115+ .addLibraries (CANONICAL_COMPILER_EXTENSIONS )
114116 .addMessageTypes (dev .cel .expr .conformance .proto2 .TestAllTypes .getDescriptor ())
115117 .addMessageTypes (dev .cel .expr .conformance .proto3 .TestAllTypes .getDescriptor ())
116118 .build ();
@@ -119,12 +121,7 @@ private static CelChecker getChecker(SimpleTest test) throws Exception {
119121 private static final CelRuntime RUNTIME =
120122 CelRuntimeFactory .standardCelRuntimeBuilder ()
121123 .setOptions (OPTIONS )
122- .addLibraries (
123- CelExtensions .encoders (OPTIONS ),
124- CelExtensions .math (OPTIONS ),
125- CelExtensions .sets (OPTIONS ),
126- CelExtensions .strings (),
127- CelOptionalLibrary .INSTANCE )
124+ .addLibraries (CANONICAL_RUNTIME_EXTENSIONS )
128125 .setExtensionRegistry (DEFAULT_EXTENSION_REGISTRY )
129126 .addMessageTypes (dev .cel .expr .conformance .proto2 .TestAllTypes .getDescriptor ())
130127 .addMessageTypes (dev .cel .expr .conformance .proto3 .TestAllTypes .getDescriptor ())
0 commit comments