MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestInliningOptimizer

Function TestInliningOptimizer

cel/inlining_test.go:318–552  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

316}
317
318func TestInliningOptimizer(t *testing.T) {
319 type varExpr struct {
320 name string
321 alias string
322 t *cel.Type
323 expr string
324 }
325 tests := []struct {
326 expr string
327 vars []varExpr
328 inlined string
329 folded string
330 }{
331 {
332 expr: `a || b`,
333 vars: []varExpr{
334 {
335 name: "a",
336 t: cel.BoolType,
337 },
338 {
339 name: "b",
340 alias: "bravo",
341 t: cel.BoolType,
342 expr: `'hello'.contains('lo')`,
343 },
344 },
345 inlined: `a || "hello".contains("lo")`,
346 folded: `true`,
347 },
348 {
349 expr: `a + [a]`,
350 vars: []varExpr{
351 {
352 name: "a",
353 alias: "alpha",
354 t: cel.DynType,
355 expr: `dyn([1, 2])`,
356 },
357 },
358 inlined: `cel.bind(alpha, dyn([1, 2]), alpha + [alpha])`,
359 folded: `[1, 2, [1, 2]]`,
360 },
361 {
362 expr: `a && (a || b)`,
363 vars: []varExpr{
364 {
365 name: "a",
366 alias: "alpha",
367 t: cel.BoolType,
368 expr: `'hello'.contains('lo')`,
369 },
370 {
371 name: "b",
372 t: cel.BoolType,
373 },
374 },
375 inlined: `cel.bind(alpha, "hello".contains("lo"), alpha && (alpha || b))`,

Callers

nothing calls this directly

Calls 15

CompileMethod · 0.95
OptimizeMethod · 0.95
OptionalTypesFunction · 0.92
EnableMacroCallTrackingFunction · 0.92
FunctionFunction · 0.92
OverloadFunction · 0.92
VariableFunction · 0.92
NewEnvFunction · 0.92
NewInlineVariableFunction · 0.92
NewStaticOptimizerFunction · 0.92
NewInliningOptimizerFunction · 0.92

Tested by

no test coverage detected