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

Function TestConstantFoldingNormalizeIDs

cel/folding_test.go:601–876  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

599}
600
601func TestConstantFoldingNormalizeIDs(t *testing.T) {
602 tests := []struct {
603 expr string
604 ids []int64
605 macros map[int64]string
606 normalizedIDs []int64
607 normalizedMacros map[int64]string
608 }{
609 {
610 expr: `[1, 2, 3]`,
611 ids: []int64{1, 2, 3, 4},
612 normalizedIDs: []int64{1, 2, 3, 4},
613 },
614 {
615 expr: `google.expr.proto3.test.TestAllTypes{single_int32: 0}`,
616 ids: []int64{1, 2, 3},
617 normalizedIDs: []int64{1, 2, 3},
618 },
619 {
620 expr: `has({x: 'value'}.single_int32)`,
621 ids: []int64{2, 3, 4, 5, 7},
622 macros: map[int64]string{7: `
623 call_expr: {
624 function: "has"
625 args: {
626 id: 6
627 select_expr: {
628 operand: {
629 id: 2
630 struct_expr: {
631 entries: {
632 id: 3
633 map_key: {
634 id: 4
635 ident_expr: {
636 name: "x"
637 }
638 }
639 value: {
640 id: 5
641 const_expr: {
642 string_value: "value"
643 }
644 }
645 }
646 }
647 }
648 field: "single_int32"
649 }
650 }
651 }`},
652 normalizedIDs: []int64{1, 2, 3, 4, 5},
653 normalizedMacros: map[int64]string{1: `
654 call_expr: {
655 function: "has"
656 args: {
657 id: 6
658 select_expr: {

Callers

nothing calls this directly

Calls 15

CompileMethod · 0.95
OptimizeMethod · 0.95
PostOrderVisitFunction · 0.92
ExprToProtoFunction · 0.92
EnableMacroCallTrackingFunction · 0.85
newIDCollectorFunction · 0.85
NewStaticOptimizerFunction · 0.85
ErrMethod · 0.80
NativeRepMethod · 0.80
NewEnvFunction · 0.70
TypesFunction · 0.70

Tested by

no test coverage detected