MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestParseErrorData

Function TestParseErrorData

parser/parser_test.go:2639–2653  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2637}
2638
2639func TestParseErrorData(t *testing.T) {
2640 p := newTestParser(t)
2641 src := common.NewTextSource(`a.?b`)
2642 _, iss := p.Parse(src)
2643 if len(iss.GetErrors()) != 1 {
2644 t.Fatalf("Check() of a bad expression did produce a single error: %v", iss.ToDisplayString())
2645 }
2646 celErr := iss.GetErrors()[0]
2647 if celErr.ExprID != 2 {
2648 t.Errorf("got exprID %v, wanted 2", celErr.ExprID)
2649 }
2650 if !strings.Contains(celErr.Message, "unsupported syntax") {
2651 t.Errorf("got message %v, wanted unsupported syntax", celErr.Message)
2652 }
2653}
2654
2655func newTestParser(t *testing.T, options ...Option) *Parser {
2656 t.Helper()

Callers

nothing calls this directly

Calls 6

NewTextSourceFunction · 0.92
newTestParserFunction · 0.85
GetErrorsMethod · 0.80
ParseMethod · 0.65
ContainsMethod · 0.65
ToDisplayStringMethod · 0.45

Tested by

no test coverage detected