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

Function TestParserOptionErrors

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

Source from the content-addressed store, hash-verified

2334}
2335
2336func TestParserOptionErrors(t *testing.T) {
2337 if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil {
2338 t.Fatalf("got %q, want %q", err, "max recursion depth must be greater than or equal to -1: -2")
2339 }
2340 if _, err := NewParser(ErrorRecoveryLimit(-2)); err == nil {
2341 t.Fatalf("got %q, want %q", err, "error recovery limit must be greater than or equal to -1: -2")
2342 }
2343 if _, err := NewParser(ErrorRecoveryLookaheadTokenLimit(0)); err == nil {
2344 t.Fatalf("got %q, want %q", err, "error recovery lookahead token limit must be at least 1: 0")
2345 }
2346 if _, err := NewParser(ErrorReportingLimit(0)); err == nil {
2347 t.Fatalf("got %q, want %q", err, "error reporting limit must be greater than 0: -2")
2348 }
2349 if _, err := NewParser(ExpressionSizeCodePointLimit(-2)); err == nil {
2350 t.Fatalf("got %q, want %q", err, "expression size code point limit must be greater than or equal to -1: -2")
2351 }
2352 if _, err := NewParser(MaxExpressionNodeCount(-2)); err == nil {
2353 t.Fatalf("got %q, want %q", err, "max expression node count must be greater than or equal to -1: -2")
2354 }
2355}
2356
2357func BenchmarkParse(b *testing.B) {
2358 p, err := NewParser(

Callers

nothing calls this directly

Calls 8

MaxRecursionDepthFunction · 0.85
ErrorRecoveryLimitFunction · 0.85
ErrorReportingLimitFunction · 0.85
MaxExpressionNodeCountFunction · 0.85
NewParserFunction · 0.70
MacrosFunction · 0.70

Tested by

no test coverage detected