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

Function TestParserOptionErrors

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

Source from the content-addressed store, hash-verified

2318}
2319
2320func TestParserOptionErrors(t *testing.T) {
2321 if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil {
2322 t.Fatalf("got %q, want %q", err, "max recursion depth must be greater than or equal to -1: -2")
2323 }
2324 if _, err := NewParser(ErrorRecoveryLimit(-2)); err == nil {
2325 t.Fatalf("got %q, want %q", err, "error recovery limit must be greater than or equal to -1: -2")
2326 }
2327 if _, err := NewParser(ErrorRecoveryLookaheadTokenLimit(0)); err == nil {
2328 t.Fatalf("got %q, want %q", err, "error recovery lookahead token limit must be at least 1: 0")
2329 }
2330 if _, err := NewParser(ErrorReportingLimit(0)); err == nil {
2331 t.Fatalf("got %q, want %q", err, "error reporting limit must be greater than 0: -2")
2332 }
2333 if _, err := NewParser(ExpressionSizeCodePointLimit(-2)); err == nil {
2334 t.Fatalf("got %q, want %q", err, "expression size code point limit must be greater than or equal to -1: -2")
2335 }
2336}
2337
2338func BenchmarkParse(b *testing.B) {
2339 p, err := NewParser(

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected