(t *testing.T)
| 1493 | } |
| 1494 | |
| 1495 | func TestConstantFoldingNormalizeIDs(t *testing.T) { |
| 1496 | tests := []struct { |
| 1497 | expr string |
| 1498 | ids []int64 |
| 1499 | macros map[int64]string |
| 1500 | normalizedIDs []int64 |
| 1501 | normalizedMacros map[int64]string |
| 1502 | }{ |
| 1503 | { |
| 1504 | expr: `[1, 2, 3]`, |
| 1505 | ids: []int64{1, 2, 3, 4}, |
| 1506 | normalizedIDs: []int64{1, 2, 3, 4}, |
| 1507 | }, |
| 1508 | { |
| 1509 | expr: `google.expr.proto3.test.TestAllTypes{single_int32: 0}`, |
| 1510 | ids: []int64{1, 2, 3}, |
| 1511 | normalizedIDs: []int64{1, 2, 3}, |
| 1512 | }, |
| 1513 | { |
| 1514 | expr: `has({x: 'value'}.single_int32)`, |
| 1515 | ids: []int64{2, 3, 4, 5, 7}, |
| 1516 | macros: map[int64]string{7: ` |
| 1517 | call_expr: { |
| 1518 | function: "has" |
| 1519 | args: { |
| 1520 | id: 6 |
| 1521 | select_expr: { |
| 1522 | operand: { |
| 1523 | id: 2 |
| 1524 | struct_expr: { |
| 1525 | entries: { |
| 1526 | id: 3 |
| 1527 | map_key: { |
| 1528 | id: 4 |
| 1529 | ident_expr: { |
| 1530 | name: "x" |
| 1531 | } |
| 1532 | } |
| 1533 | value: { |
| 1534 | id: 5 |
| 1535 | const_expr: { |
| 1536 | string_value: "value" |
| 1537 | } |
| 1538 | } |
| 1539 | } |
| 1540 | } |
| 1541 | } |
| 1542 | field: "single_int32" |
| 1543 | } |
| 1544 | } |
| 1545 | }`}, |
| 1546 | normalizedIDs: []int64{1, 2, 3, 4, 5}, |
| 1547 | normalizedMacros: map[int64]string{1: ` |
| 1548 | call_expr: { |
| 1549 | function: "has" |
| 1550 | args: { |
| 1551 | id: 6 |
| 1552 | select_expr: { |
nothing calls this directly
no test coverage detected