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

Function TestConstantFoldingNormalizeIDs

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

Source from the content-addressed store, hash-verified

924}
925
926func TestConstantFoldingNormalizeIDs(t *testing.T) {
927 tests := []struct {
928 expr string
929 ids []int64
930 macros map[int64]string
931 normalizedIDs []int64
932 normalizedMacros map[int64]string
933 }{
934 {
935 expr: `[1, 2, 3]`,
936 ids: []int64{1, 2, 3, 4},
937 normalizedIDs: []int64{1, 2, 3, 4},
938 },
939 {
940 expr: `google.expr.proto3.test.TestAllTypes{single_int32: 0}`,
941 ids: []int64{1, 2, 3},
942 normalizedIDs: []int64{1, 2, 3},
943 },
944 {
945 expr: `has({x: 'value'}.single_int32)`,
946 ids: []int64{2, 3, 4, 5, 7},
947 macros: map[int64]string{7: `
948 call_expr: {
949 function: "has"
950 args: {
951 id: 6
952 select_expr: {
953 operand: {
954 id: 2
955 struct_expr: {
956 entries: {
957 id: 3
958 map_key: {
959 id: 4
960 ident_expr: {
961 name: "x"
962 }
963 }
964 value: {
965 id: 5
966 const_expr: {
967 string_value: "value"
968 }
969 }
970 }
971 }
972 }
973 field: "single_int32"
974 }
975 }
976 }`},
977 normalizedIDs: []int64{1, 2, 3, 4, 5},
978 normalizedMacros: map[int64]string{1: `
979 call_expr: {
980 function: "has"
981 args: {
982 id: 6
983 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