Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bundle/src/main/java/dev/cel/bundle/CelEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public abstract class CelEnvironment {
"optional", CanonicalCelExtension.OPTIONAL,
"protos", CanonicalCelExtension.PROTOS,
"sets", CanonicalCelExtension.SETS,
"strings", CanonicalCelExtension.STRINGS);
"strings", CanonicalCelExtension.STRINGS,
"comprehensions", CanonicalCelExtension.COMPREHENSIONS);

/** Environment source in textual format (ex: textproto, YAML). */
public abstract Optional<Source> source();
Expand Down Expand Up @@ -687,8 +688,8 @@ enum CanonicalCelExtension {
BINDINGS((options, version) -> CelExtensions.bindings()),
PROTOS((options, version) -> CelExtensions.protos()),
ENCODERS(
(options, version) -> CelExtensions.encoders(),
(options, version) -> CelExtensions.encoders()),
(options, version) -> CelExtensions.encoders(options),
(options, version) -> CelExtensions.encoders(options)),
MATH(
(options, version) -> CelExtensions.math(options, version),
(options, version) -> CelExtensions.math(options, version)),
Expand All @@ -701,7 +702,10 @@ enum CanonicalCelExtension {
SETS(
(options, version) -> CelExtensions.sets(options),
(options, version) -> CelExtensions.sets(options)),
LISTS((options, version) -> CelExtensions.lists(), (options, version) -> CelExtensions.lists());
LISTS((options, version) -> CelExtensions.lists(), (options, version) -> CelExtensions.lists()),
COMPREHENSIONS(
(options, version) -> CelExtensions.comprehensions(),
(options, version) -> CelExtensions.comprehensions());

@SuppressWarnings("ImmutableEnumChecker")
private final CompilerExtensionProvider compilerExtensionProvider;
Expand Down
18 changes: 8 additions & 10 deletions bundle/src/test/java/dev/cel/bundle/CelEnvironmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void extend_allExtensions() throws Exception {
ExtensionConfig.latest("optional"),
ExtensionConfig.latest("protos"),
ExtensionConfig.latest("sets"),
ExtensionConfig.latest("strings"));
ExtensionConfig.latest("strings"),
ExtensionConfig.latest("comprehensions"));
CelEnvironment environment =
CelEnvironment.newBuilder().addExtensions(extensionConfigs).build();

Expand Down Expand Up @@ -100,9 +101,7 @@ public void extensionVersion_specific() throws Exception {
@Test
public void extensionVersion_latest() throws Exception {
CelEnvironment environment =
CelEnvironment.newBuilder()
.addExtensions(ExtensionConfig.latest("math"))
.build();
CelEnvironment.newBuilder().addExtensions(ExtensionConfig.latest("math")).build();

Cel cel = environment.extend(CelFactory.standardCelBuilder().build(), CelOptions.DEFAULT);
CelAbstractSyntaxTree ast = cel.compile("math.sqrt(4)").getAst();
Expand Down Expand Up @@ -240,10 +239,10 @@ public void stdlibSubset_functionsIncluded() throws Exception {
LibrarySubset.newBuilder()
.setDisabled(false)
.setIncludedFunctions(
ImmutableSet.of(
FunctionSelector.create("_==_", ImmutableSet.of()),
FunctionSelector.create("_!=_", ImmutableSet.of()),
FunctionSelector.create("_&&_", ImmutableSet.of())))
ImmutableSet.of(
FunctionSelector.create("_==_", ImmutableSet.of()),
FunctionSelector.create("_!=_", ImmutableSet.of()),
FunctionSelector.create("_&&_", ImmutableSet.of())))
.build())
.build();

Expand Down Expand Up @@ -287,8 +286,7 @@ public void stdlibSubset_functionsExcluded() throws Exception {
LibrarySubset.newBuilder()
.setDisabled(false)
.setExcludedFunctions(
ImmutableSet.of(
FunctionSelector.create("_+_", ImmutableSet.of())))
ImmutableSet.of(FunctionSelector.create("_+_", ImmutableSet.of())))
.build())
.build();

Expand Down