(t *testing.T)
| 597 | } |
| 598 | |
| 599 | func TestTwoVarComprehensionsResidualAST(t *testing.T) { |
| 600 | tests := []struct { |
| 601 | name string |
| 602 | in map[string]any |
| 603 | varOpts []cel.EnvOption |
| 604 | unks []*interpreter.AttributePattern |
| 605 | expr string |
| 606 | residual string |
| 607 | }{ |
| 608 | { |
| 609 | name: "transform map entry residual compare", |
| 610 | varOpts: []cel.EnvOption{ |
| 611 | cel.Variable("x", cel.ListType(cel.DynType)), |
| 612 | cel.Variable("y", cel.IntType), |
| 613 | }, |
| 614 | in: map[string]any{ |
| 615 | "x": []any{0, uint(1)}, |
| 616 | }, |
| 617 | unks: []*interpreter.AttributePattern{cel.AttributePattern("y")}, |
| 618 | expr: `x.transformMapEntry(i, v, {v: i}).size() < y`, |
| 619 | residual: `2 < y`, |
| 620 | }, |
| 621 | { |
| 622 | name: "transform map entry residual transform", |
| 623 | varOpts: []cel.EnvOption{ |
| 624 | cel.Variable("x", cel.ListType(cel.DynType)), |
| 625 | cel.Variable("y", cel.IntType), |
| 626 | }, |
| 627 | in: map[string]any{ |
| 628 | "x": []any{0, uint(1)}, |
| 629 | }, |
| 630 | unks: []*interpreter.AttributePattern{cel.AttributePattern("y")}, |
| 631 | expr: `x.transformMapEntry(i, v, i < y, {v: i})`, |
| 632 | residual: `[0, 1u].transformMapEntry(i, v, i < y, {v: i})`, |
| 633 | }, |
| 634 | { |
| 635 | name: "nested exists unknown inner range", |
| 636 | varOpts: []cel.EnvOption{ |
| 637 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 638 | cel.Variable("y", cel.MapType(cel.IntType, cel.DynType)), |
| 639 | }, |
| 640 | in: map[string]any{ |
| 641 | "x": []any{1, 2, 3}, |
| 642 | }, |
| 643 | unks: []*interpreter.AttributePattern{cel.AttributePattern("y")}, |
| 644 | expr: `x.exists(val, y.exists(key, _, key == val))`, |
| 645 | residual: `[1, 2, 3].exists(val, y.exists(key, _, key == val))`, |
| 646 | }, |
| 647 | { |
| 648 | name: "nested exists unknown inner range", |
| 649 | varOpts: []cel.EnvOption{ |
| 650 | cel.Variable("x", cel.ListType(cel.IntType)), |
| 651 | cel.Variable("y", cel.MapType(cel.IntType, cel.DynType)), |
| 652 | }, |
| 653 | in: map[string]any{ |
| 654 | "y": map[int]string{1: "hi", 2: "hello", 3: "howdy"}, |
| 655 | }, |
| 656 | unks: []*interpreter.AttributePattern{cel.AttributePattern("x")}, |
nothing calls this directly
no test coverage detected