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

Function TestParseErrorData

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

Source from the content-addressed store, hash-verified

2394}
2395
2396func TestParseErrorData(t *testing.T) {
2397 p := newTestParser(t)
2398 src := common.NewTextSource(`a.?b`)
2399 _, iss := p.Parse(src)
2400 if len(iss.GetErrors()) != 1 {
2401 t.Fatalf("Check() of a bad expression did produce a single error: %v", iss.ToDisplayString())
2402 }
2403 celErr := iss.GetErrors()[0]
2404 if celErr.ExprID != 2 {
2405 t.Errorf("got exprID %v, wanted 2", celErr.ExprID)
2406 }
2407 if !strings.Contains(celErr.Message, "unsupported syntax") {
2408 t.Errorf("got message %v, wanted unsupported syntax", celErr.Message)
2409 }
2410}
2411
2412func newTestParser(t *testing.T, options ...Option) *Parser {
2413 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