@@ -138,9 +138,7 @@ describe("Performance measurements", () => {
138138 console . log ( `Execution took ${ executeTime . toFixed ( 0 ) } nanoseconds` ) ;
139139
140140 // Measure one-step evaluation time
141- const [ , evaluateTime ] = await measureTime ( ( ) =>
142- CelProgram . evaluate ( expr , context ) ,
143- ) ;
141+ const [ , evaluateTime ] = await measureTime ( ( ) => evaluate ( expr , context ) ) ;
144142 console . log (
145143 `One-step evaluation took ${ evaluateTime . toFixed ( 0 ) } nanoseconds` ,
146144 ) ;
@@ -159,44 +157,3 @@ describe("Performance measurements", () => {
159157 expect ( evaluateTime ) . toBeLessThan ( expectedEvaluateTime * ( 1 + tolerance ) ) ;
160158 } ) ;
161159} ) ;
162-
163- describe ( "CelProgram.evaluate" , ( ) => {
164- it ( "should evaluate a simple expression in one step" , async ( ) => {
165- const result = await CelProgram . evaluate ( "size(message) > 5" , {
166- message : "Hello World" ,
167- } ) ;
168- expect ( result ) . toBe ( true ) ;
169- } ) ;
170-
171- it ( "should handle errors gracefully" , async ( ) => {
172- await expect (
173- CelProgram . evaluate ( "invalid expression" , { } ) ,
174- ) . rejects . toThrow ( ) ;
175- } ) ;
176-
177- it ( "should handle complex expressions and data structures" , async ( ) => {
178- const result = await CelProgram . evaluate (
179- '{"name": "test", "items": [1, 2, 3].map(i, {"id": i})}' ,
180- { } ,
181- ) ;
182- expect ( result ) . toEqual ( {
183- name : "test" ,
184- items : [ { id : 1 } , { id : 2 } , { id : 3 } ] ,
185- } ) ;
186- } ) ;
187-
188- it ( "should handle cart validation in one step" , async ( ) => {
189- const expr =
190- 'has(cart.items) && cart.items.exists(item, item.productId == "prod_123" && item.quantity >= 1)' ;
191- const result = await CelProgram . evaluate ( expr , {
192- cart : {
193- items : [
194- { productId : "prod_456" , quantity : 1 } ,
195- { productId : "prod_123" , quantity : 1 } ,
196- { productId : "prod_789" , quantity : 3 } ,
197- ] ,
198- } ,
199- } ) ;
200- expect ( result ) . toBe ( true ) ;
201- } ) ;
202- } ) ;
0 commit comments