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

Function TestParserOptionErrors

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

Source from the content-addressed store, hash-verified

2942}
2943
2944func TestParserOptionErrors(t *testing.T) {
2945 if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil {
2946 t.Fatalf("got %q, want %q", err, "max recursion depth must be greater than or equal to -1: -2")
2947 }
2948 if _, err := NewParser(ErrorRecoveryLimit(-2)); err == nil {
2949 t.Fatalf("got %q, want %q", err, "error recovery limit must be greater than or equal to -1: -2")
2950 }
2951 if _, err := NewParser(ErrorRecoveryLookaheadTokenLimit(0)); err == nil {
2952 t.Fatalf("got %q, want %q", err, "error recovery lookahead token limit must be at least 1: 0")
2953 }
2954 if _, err := NewParser(ErrorReportingLimit(0)); err == nil {
2955 t.Fatalf("got %q, want %q", err, "error reporting limit must be greater than 0: -2")
2956 }
2957 if _, err := NewParser(ExpressionSizeCodePointLimit(-2)); err == nil {
2958 t.Fatalf("got %q, want %q", err, "expression size code point limit must be greater than or equal to -1: -2")
2959 }
2960 if _, err := NewParser(MaxExpressionNodeCount(-2)); err == nil {
2961 t.Fatalf("got %q, want %q", err, "max expression node count must be greater than or equal to -1: -2")
2962 }
2963}
2964
2965func TestSourceInfoPositions(t *testing.T) {
2966 for _, pratt := range []bool{false, true} {

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