(t *testing.T)
| 2923 | } |
| 2924 | |
| 2925 | func TestMaxExpressionNodeCount(t *testing.T) { |
| 2926 | for _, pratt := range []bool{false, true} { |
| 2927 | t.Run(fmt.Sprintf("enablePrattParser=%t", pratt), func(t *testing.T) { |
| 2928 | p, err := NewParser(Macros(AllMacros...), MaxExpressionNodeCount(10), EnablePrattParser(pratt)) |
| 2929 | if err != nil { |
| 2930 | t.Fatal(err) |
| 2931 | } |
| 2932 | src := common.NewTextSource("a.exists(x, x.exists(y, y == 1))") |
| 2933 | _, errs := p.Parse(src) |
| 2934 | if len(errs.GetErrors()) == 0 { |
| 2935 | t.Fatalf("expected errors, got none: %s", errs.ToDisplayString()) |
| 2936 | } |
| 2937 | if !strings.Contains(errs.GetErrors()[0].Message, "expression count exceeds limit of 10 while expanding macro 'exists'") { |
| 2938 | t.Fatalf("got %q, want substring matching limit error: %s", errs.GetErrors()[0].Message, errs.GetErrors()[0].ToDisplayString(src)) |
| 2939 | } |
| 2940 | }) |
| 2941 | } |
| 2942 | } |
| 2943 | |
| 2944 | func TestParserOptionErrors(t *testing.T) { |
| 2945 | if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil { |
nothing calls this directly
no test coverage detected