MCPcopy
hub / github.com/expr-lang/expr / TestExpr_timeout

Function TestExpr_timeout

expr_test.go:2355–2390  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2353}
2354
2355func TestExpr_timeout(t *testing.T) {
2356 tests := []struct{ code string }{
2357 {`-999999..999999`},
2358 {`map(1..999999, 1..999999)`},
2359 {`map(1..999999, repeat('a', #))`},
2360 }
2361
2362 for _, tt := range tests {
2363 t.Run(tt.code, func(t *testing.T) {
2364 program, err := expr.Compile(tt.code)
2365 require.NoError(t, err)
2366
2367 timeout := make(chan bool, 1)
2368 go func() {
2369 time.Sleep(time.Second)
2370 timeout <- true
2371 }()
2372
2373 done := make(chan bool, 1)
2374 go func() {
2375 out, err := expr.Run(program, nil)
2376 // Make sure out is used.
2377 _ = fmt.Sprintf("%v", out)
2378 assert.Error(t, err)
2379 done <- true
2380 }()
2381
2382 select {
2383 case <-done:
2384 // Success.
2385 case <-timeout:
2386 t.Fatal("timeout")
2387 }
2388 })
2389 }
2390}
2391
2392func TestIssue432(t *testing.T) {
2393 env := map[string]any{

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
ErrorFunction · 0.92
RunMethod · 0.80
SprintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…