(t *testing.T)
| 2815 | } |
| 2816 | |
| 2817 | func TestCheckErrorData(t *testing.T) { |
| 2818 | p, err := parser.NewParser( |
| 2819 | parser.EnableOptionalSyntax(true), |
| 2820 | parser.Macros(parser.AllMacros...), |
| 2821 | ) |
| 2822 | if err != nil { |
| 2823 | t.Fatalf("parser.NewParser() failed: %v", err) |
| 2824 | } |
| 2825 | src := common.NewTextSource(`a || true`) |
| 2826 | ast, iss := p.Parse(src) |
| 2827 | if len(iss.GetErrors()) != 0 { |
| 2828 | t.Fatalf("Parse() failed: %v", iss.ToDisplayString()) |
| 2829 | } |
| 2830 | |
| 2831 | reg := newTestRegistry(t) |
| 2832 | env, err := NewEnv(containers.DefaultContainer, reg) |
| 2833 | if err != nil { |
| 2834 | t.Fatalf("NewEnv(cont, reg) failed: %v", err) |
| 2835 | } |
| 2836 | env.AddFunctions(stdlib.Functions()...) |
| 2837 | _, iss = Check(ast, src, env) |
| 2838 | if len(iss.GetErrors()) != 1 { |
| 2839 | t.Fatalf("Check() of a bad expression did produce a single error: %v", iss.ToDisplayString()) |
| 2840 | } |
| 2841 | celErr := iss.GetErrors()[0] |
| 2842 | if celErr.ExprID != 1 { |
| 2843 | t.Errorf("got exprID %v, wanted 1", celErr.ExprID) |
| 2844 | } |
| 2845 | if !strings.Contains(celErr.Message, "undeclared reference") { |
| 2846 | t.Errorf("got message %v, wanted undeclared reference", celErr.Message) |
| 2847 | } |
| 2848 | } |
| 2849 | |
| 2850 | func TestCheckInvalidOptSelectMember(t *testing.T) { |
| 2851 | fac := ast.NewExprFactory() |
nothing calls this directly
no test coverage detected