(t *testing.T)
| 2773 | } |
| 2774 | |
| 2775 | func TestCheckErrorData(t *testing.T) { |
| 2776 | p, err := parser.NewParser( |
| 2777 | parser.EnableOptionalSyntax(true), |
| 2778 | parser.Macros(parser.AllMacros...), |
| 2779 | ) |
| 2780 | if err != nil { |
| 2781 | t.Fatalf("parser.NewParser() failed: %v", err) |
| 2782 | } |
| 2783 | src := common.NewTextSource(`a || true`) |
| 2784 | ast, iss := p.Parse(src) |
| 2785 | if len(iss.GetErrors()) != 0 { |
| 2786 | t.Fatalf("Parse() failed: %v", iss.ToDisplayString()) |
| 2787 | } |
| 2788 | |
| 2789 | reg := newTestRegistry(t) |
| 2790 | env, err := NewEnv(containers.DefaultContainer, reg) |
| 2791 | if err != nil { |
| 2792 | t.Fatalf("NewEnv(cont, reg) failed: %v", err) |
| 2793 | } |
| 2794 | env.AddFunctions(stdlib.Functions()...) |
| 2795 | _, iss = Check(ast, src, env) |
| 2796 | if len(iss.GetErrors()) != 1 { |
| 2797 | t.Fatalf("Check() of a bad expression did produce a single error: %v", iss.ToDisplayString()) |
| 2798 | } |
| 2799 | celErr := iss.GetErrors()[0] |
| 2800 | if celErr.ExprID != 1 { |
| 2801 | t.Errorf("got exprID %v, wanted 1", celErr.ExprID) |
| 2802 | } |
| 2803 | if !strings.Contains(celErr.Message, "undeclared reference") { |
| 2804 | t.Errorf("got message %v, wanted undeclared reference", celErr.Message) |
| 2805 | } |
| 2806 | } |
| 2807 | |
| 2808 | func TestCheckInvalidOptSelectMember(t *testing.T) { |
| 2809 | fac := ast.NewExprFactory() |
nothing calls this directly
no test coverage detected