(t *testing.T)
| 1692 | } |
| 1693 | |
| 1694 | func TestParseWithMacroTracking(t *testing.T) { |
| 1695 | env := testEnv(t, EnableMacroCallTracking()) |
| 1696 | ast, iss := env.Parse("has(a.b) && a.b.exists(c, c < 10)") |
| 1697 | if iss.Err() != nil { |
| 1698 | t.Fatalf("e.Parse() failed: %v", iss.Err()) |
| 1699 | } |
| 1700 | pe, err := AstToParsedExpr(ast) |
| 1701 | if err != nil { |
| 1702 | t.Fatalf("AstToParsedExpr(%v) failed: %v", ast, err) |
| 1703 | } |
| 1704 | macroCalls := pe.GetSourceInfo().GetMacroCalls() |
| 1705 | if len(macroCalls) != 2 { |
| 1706 | t.Errorf("got %d macro calls, wanted 2", len(macroCalls)) |
| 1707 | } |
| 1708 | callsFound := map[string]bool{"has": false, "exists": false} |
| 1709 | for _, expr := range macroCalls { |
| 1710 | f := expr.GetCallExpr().GetFunction() |
| 1711 | _, found := callsFound[f] |
| 1712 | if !found { |
| 1713 | t.Errorf("Unexpected macro call: %v", expr) |
| 1714 | } |
| 1715 | callsFound[f] = true |
| 1716 | } |
| 1717 | callsWanted := map[string]bool{"has": true, "exists": true} |
| 1718 | if !reflect.DeepEqual(callsFound, callsWanted) { |
| 1719 | t.Errorf("Tracked calls %v, but wanted %v", callsFound, callsWanted) |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | func TestParseAndCheckConcurrently(t *testing.T) { |
| 1724 | env := testEnv(t, |
nothing calls this directly
no test coverage detected