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

Function TestErrorRecoveryLimits

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

Source from the content-addressed store, hash-verified

3117}
3118
3119func TestErrorRecoveryLimits(t *testing.T) {
3120 for _, pratt := range []bool{false, true} {
3121 t.Run(fmt.Sprintf("enablePrattParser=%t", pratt), func(t *testing.T) {
3122 t.Run("LimitZero", func(t *testing.T) {
3123 p, err := NewParser(ErrorRecoveryLimit(0), EnablePrattParser(pratt))
3124 if err != nil {
3125 t.Fatalf("NewParser() failed: %v", err)
3126 }
3127 _, errs := p.Parse(common.NewTextSource("......"))
3128 if len(errs.GetErrors()) == 0 {
3129 t.Errorf("expected error recovery limit error, got none")
3130 }
3131 })
3132
3133 t.Run("LimitOne", func(t *testing.T) {
3134 p, err := NewParser(ErrorRecoveryLimit(1), EnablePrattParser(pratt))
3135 if err != nil {
3136 t.Fatalf("NewParser() failed: %v", err)
3137 }
3138 _, errs := p.Parse(common.NewTextSource("......"))
3139 if len(errs.GetErrors()) == 0 {
3140 t.Errorf("expected error recovery limit error, got none")
3141 }
3142 })
3143 })
3144 }
3145}
3146
3147func wrapInParens(inner string, count int) string {
3148 return strings.Repeat("(", count) + inner + strings.Repeat(")", count)

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.95
NewTextSourceFunction · 0.92
ErrorRecoveryLimitFunction · 0.85
EnablePrattParserFunction · 0.85
GetErrorsMethod · 0.80
NewParserFunction · 0.70

Tested by

no test coverage detected