(t *testing.T)
| 956 | } |
| 957 | |
| 958 | func 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: { |
nothing calls this directly
no test coverage detected