Skip to content

Commit 23fffba

Browse files
committed
feat(cel-proto-parser): add round-trip testing utilities and AST converter
- Add @marcbachmann/cel-js as dependency for CEL parsing - Create AST converter from @marcbachmann/cel-js format to CEL proto format - Create TestUtil class (CelTest) for round-trip testing similar to pgsql-parser - Add CEL expression fixtures for testing - Add comprehensive converter and integration tests (31 new tests) - Add test-roundtrip.ts script for ESM-based round-trip testing - Export convertToProtoExpr and MarcAstNode from main index
1 parent a268c09 commit 23fffba

8 files changed

Lines changed: 1310 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# CEL Expression Fixtures
2+
# Each line is a CEL expression to test for round-trip parsing
3+
# Lines starting with # are comments
4+
5+
# Literals
6+
1
7+
42
8+
-5
9+
3.14
10+
-2.5
11+
1.0
12+
true
13+
false
14+
null
15+
"hello"
16+
"hello world"
17+
"with \"quotes\""
18+
"with\nnewline"
19+
""
20+
21+
# Unsigned integers
22+
1u
23+
42u
24+
0u
25+
26+
# Identifiers
27+
x
28+
foo
29+
request
30+
_underscore
31+
camelCase
32+
33+
# Field access
34+
request.auth
35+
request.auth.claims
36+
request.auth.claims.email
37+
a.b.c.d
38+
39+
# Arithmetic operators
40+
1 + 2
41+
a + b
42+
x - y
43+
a * b
44+
x / y
45+
a % b
46+
1 + 2 * 3
47+
(1 + 2) * 3
48+
49+
# Comparison operators
50+
a == b
51+
x != y
52+
a < b
53+
a <= b
54+
a > b
55+
a >= b
56+
57+
# Logical operators
58+
a && b
59+
x || y
60+
!a
61+
a && b && c
62+
a || b || c
63+
a && b || c
64+
(a || b) && c
65+
66+
# Ternary conditional
67+
x ? 1 : 2
68+
a == b ? "yes" : "no"
69+
x > 0 ? x : -x
70+
71+
# List literals
72+
[]
73+
[1]
74+
[1, 2, 3]
75+
[a, b, c]
76+
["a", "b", "c"]
77+
78+
# Map literals
79+
{}
80+
{"a": 1}
81+
{"a": 1, "b": 2}
82+
{1: "one", 2: "two"}
83+
84+
# Index access
85+
list[0]
86+
map["key"]
87+
a[b]
88+
list[i + 1]
89+
90+
# Function calls
91+
size(list)
92+
int(x)
93+
string(42)
94+
type(x)
95+
96+
# Method calls
97+
list.size()
98+
str.contains("test")
99+
list.map(x, x * 2)
100+
101+
# In operator
102+
x in list
103+
"admin" in roles
104+
key in map
105+
106+
# Complex expressions
107+
request.auth.claims.email == "admin@example.com"
108+
size(request.body) > 0 && request.method == "POST"
109+
user.age >= 18 && "admin" in user.roles
110+
items.all(x, x > 0)
111+
items.exists(x, x == target)

0 commit comments

Comments
 (0)