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

Function TestConstantFoldingNormalizeIDs

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

Source from the content-addressed store, hash-verified

956}
957
958func TestConstantFoldingNormalizeIDs(t *testing.T) {
959 tests := []struct {
960 expr string
961 ids []int64
962 macros map[int64]string
963 normalizedIDs []int64
964 normalizedMacros map[int64]string
965 }{
966 {
967 expr: `[1, 2, 3]`,
968 ids: []int64{1, 2, 3, 4},
969 normalizedIDs: []int64{1, 2, 3, 4},
970 },
971 {
972 expr: `google.expr.proto3.test.TestAllTypes{single_int32: 0}`,
973 ids: []int64{1, 2, 3},
974 normalizedIDs: []int64{1, 2, 3},
975 },
976 {
977 expr: `has({x: 'value'}.single_int32)`,
978 ids: []int64{2, 3, 4, 5, 7},
979 macros: map[int64]string{7: `
980 call_expr: {
981 function: "has"
982 args: {
983 id: 6
984 select_expr: {
985 operand: {
986 id: 2
987 struct_expr: {
988 entries: {
989 id: 3
990 map_key: {
991 id: 4
992 ident_expr: {
993 name: "x"
994 }
995 }
996 value: {
997 id: 5
998 const_expr: {
999 string_value: "value"
1000 }
1001 }
1002 }
1003 }
1004 }
1005 field: "single_int32"
1006 }
1007 }
1008 }`},
1009 normalizedIDs: []int64{1, 2, 3, 4, 5},
1010 normalizedMacros: map[int64]string{1: `
1011 call_expr: {
1012 function: "has"
1013 args: {
1014 id: 6
1015 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