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

Function TestParseErrorData

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

Source from the content-addressed store, hash-verified

2376}
2377
2378func TestParseErrorData(t *testing.T) {
2379 p := newTestParser(t)
2380 src := common.NewTextSource(`a.?b`)
2381 _, iss := p.Parse(src)
2382 if len(iss.GetErrors()) != 1 {
2383 t.Fatalf("Check() of a bad expression did produce a single error: %v", iss.ToDisplayString())
2384 }
2385 celErr := iss.GetErrors()[0]
2386 if celErr.ExprID != 2 {
2387 t.Errorf("got exprID %v, wanted 2", celErr.ExprID)
2388 }
2389 if !strings.Contains(celErr.Message, "unsupported syntax") {
2390 t.Errorf("got message %v, wanted unsupported syntax", celErr.Message)
2391 }
2392}
2393
2394func newTestParser(t *testing.T, options ...Option) *Parser {
2395 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