Skip to content

Commit b56841e

Browse files
committed
make cel-rust pass conformance tests
1 parent a835a1b commit b56841e

34 files changed

+12917
-326
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "cel-spec"]
2+
path = cel-spec
3+
url = https://github.com/google/cel-spec.git

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["cel", "example", "fuzz"]
2+
members = ["cel", "example", "fuzz", "conformance"]
33
resolver = "2"
44

55
[profile.bench]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ for simplicity, speed, safety, and
77
portability. CEL's C-like syntax looks nearly identical to equivalent expressions in C++, Go, Java, and TypeScript. CEL
88
is ideal for lightweight expression evaluation when a fully sandboxed scripting language is too resource intensive.
99

10+
It passes all conformance tests.
11+
1012
```java
1113
// Check whether a resource name starts with a group name.
1214
resource.name.startsWith("/groups/" + auth.claims.group)
@@ -28,7 +30,7 @@ Add `cel` to your `Cargo.toml`:
2830

2931
```toml
3032
[dependencies]
31-
cel = "0.11.6"
33+
cel = "0.12.0"
3234
```
3335

3436
Create and execute a simple CEL expression:

cel-spec

Submodule cel-spec added at 121e265

cel/CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.12.0](https://github.com/cel-rust/cel-rust/compare/v0.11.6...v0.12.0) - 2025-12-29
11+
12+
### Added
13+
14+
- *(Optional)* Initial support
15+
- *(opaque)* docs
16+
- *(opaque)* PR comments addressed
17+
- *(Opaque)* json support
18+
- *(Opaque)* No indirection, straight holds trait OpaqueValue
19+
- *(opaque)* no need for as_any
20+
- *(opaque)* Equality of opaques
21+
- *(opaque)* wire function example
22+
- *(opaque)* Adds support for `OpaqueValue`s
23+
- *(parser)* Proper support for comments
24+
25+
### Fixed
26+
27+
- fix formatting
28+
- fix logic and function naming
29+
- fixup test
30+
- *(opaque)* Refactor OpaqueValue to simply Opaque
31+
- account for feature chrono in Debug
32+
- remove dep
33+
- *(arbitrary)* no more arbitratry in the main crate
34+
- *(arbitrary)* less pervasive usage
35+
36+
### Other
37+
38+
- Merge pull request #240 from Rick-Phoenix/bytes-support
39+
- Update README example to use CEL 0.12.0 ([#242](https://github.com/cel-rust/cel-rust/pull/242))
40+
- Support get{Hours,Minutes,Seconds,Milliseconds} on duration
41+
- Merge pull request #234 from adam-cattermole/optional
42+
- Optional tests use Parser directly
43+
- Initialize lists and maps with optionals in interpreter
44+
- Handle optional index in interpreter
45+
- Fix should error on missing map key
46+
- Handle optional select in interpreter
47+
- Handle optionals in lists in parser
48+
- Handle optional struct/map initializer in parser
49+
- Add optional visit_Select/Index to parser
50+
- Add enable_optional_syntax option to parser
51+
- Add orValue function for optional
52+
- Add or function for optional
53+
- Add hasValue function for optional
54+
- Add value function for optional
55+
- Add optional.ofNonZeroValue
56+
- Add optional.of
57+
- Documentation and pass reference
58+
- Add new way to resolve variables
59+
- default to BTree's instead of HashMap ([#231](https://github.com/cel-rust/cel-rust/pull/231))
60+
- avoid cloning function args and name ([#228](https://github.com/cel-rust/cel-rust/pull/228))
61+
- avoid double resolving single-arg func calls ([#227](https://github.com/cel-rust/cel-rust/pull/227))
62+
- move
63+
- minor tweaks to make usage more ergonomic
64+
- Fix Context docstring to reference new_inner_scope instead of clone ([#221](https://github.com/cel-rust/cel-rust/pull/221))
65+
1066
## [0.11.6](https://github.com/cel-rust/cel-rust/compare/v0.11.5...v0.11.6) - 2025-10-23
1167

1268
### Added

cel/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
name = "cel"
33
description = "A parser and interpreter for the Common Expression Language (CEL)"
44
repository = "https://github.com/cel-rust/cel-rust"
5-
version = "0.11.6"
5+
version = "0.12.0"
66
authors = ["Clark McCauley <me@clarkmccauley.com>", "Alex Snaps <alex@wcgw.dev>"]
77
edition = "2021"
8-
rust-version = "1.82.0"
8+
rust-version = "1.86.0"
99
license = "MIT"
1010
categories = ["compilers"]
1111

@@ -14,10 +14,13 @@ antlr4rust = "0.5.2"
1414
lazy_static = "1.5.0"
1515
nom = "7.1.3"
1616
chrono = { version = "0.4", default-features = false, features = ["alloc", "serde"], optional = true }
17+
chrono-tz = { version = "0.8", optional = true }
1718
regex = { version = "1.10.5", optional = true }
1819
serde = "1.0"
1920
serde_json = { version = "1.0", optional = true }
2021
base64 = { version = "0.22.1", optional = true }
22+
prost = { version = "0.12", optional = true }
23+
bytes = { version = "1", optional = true }
2124

2225
thiserror = "1.0"
2326
paste = "1.0"
@@ -33,7 +36,9 @@ harness = false
3336

3437
[features]
3538
default = ["regex", "chrono"]
39+
bytes = ["dep:bytes"]
3640
json = ["dep:serde_json", "dep:base64"]
3741
regex = ["dep:regex"]
38-
chrono = ["dep:chrono"]
42+
chrono = ["dep:chrono", "dep:chrono-tz"]
43+
proto = ["dep:prost"]
3944
dhat-heap = [ ] # if you are doing heap profiling

cel/benches/runtime.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ use cel::{Program, Value};
33
use criterion::{black_box, criterion_group, BenchmarkId, Criterion};
44
use std::collections::HashMap;
55

6-
const EXPRESSIONS: [(&str, &str); 36] = [
7-
("ternary_1", "(1 || 2) ? 1 : 2"),
8-
("ternary_2", "(1 ? 2 : 3) ? 1 : 2"),
9-
("or_1", "1 || 2"),
10-
("and_1", "1 && 2"),
11-
("and_2", "1 && (false ? 2 : 3)"),
6+
const EXPRESSIONS: [(&str, &str); 34] = [
7+
("ternary_1", "(false || true) ? 1 : 2"),
8+
("ternary_2", "(true ? false : true) ? 1 : 2"),
9+
("or_1", "false || true"),
10+
("and_1", "true && false"),
11+
("and_2", "true && (false ? 2 : 3) > 2"),
1212
("number", "1"),
1313
("construct_list", "[1,2,3]"),
1414
("construct_list_1", "[1]"),
15-
("construct_list_2", "[1, 2]"),
15+
("construct_list_2", "[a, 2]"),
1616
("add_list", "[1,2,3] + [4, 5, 6]"),
1717
("list_element", "[1,2,3][1]"),
1818
("construct_dict", "{1: 2, '3': '4'}"),
1919
("add_string", "'abc' + 'def'"),
20-
("list", "[1,2,3, Now, ]"),
2120
("mapexpr", "{1 + a: 3}"),
22-
("map_merge", "{'a': 1} + {'a': 2, 'b': 3}"),
2321
("size_list", "[1].size()"),
2422
("size_list_1", "size([1])"),
2523
("size_str", "'a'.size()"),
@@ -67,8 +65,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
6765
let mut ctx = Context::default();
6866
ctx.add_variable_from_value("foo", HashMap::from([("bar", 1)]));
6967
ctx.add_variable_from_value("apple", true);
68+
ctx.add_variable_from_value("a", 1);
7069
ctx.set_variable_resolver(&Resolver);
71-
b.iter(|| program.execute(&ctx))
70+
b.iter(|| program.execute(&ctx).expect("Eval failed!"))
7271
});
7372
}
7473
}
@@ -92,7 +91,7 @@ pub fn map_macro_benchmark(c: &mut Criterion) {
9291
let program = Program::compile("list.map(x, x * 2)").unwrap();
9392
let mut ctx = Context::default();
9493
ctx.add_variable_from_value("list", list);
95-
b.iter(|| program.execute(&ctx).unwrap())
94+
b.iter(|| program.execute(&ctx).expect("Eval failed!"))
9695
});
9796
}
9897
group.finish();

0 commit comments

Comments
 (0)