| 2333 | } |
| 2334 | |
| 2335 | func TestEval_slices_out_of_bound(t *testing.T) { |
| 2336 | tests := []struct { |
| 2337 | code string |
| 2338 | want any |
| 2339 | }{ |
| 2340 | {"[1, 2, 3][:99]", []any{1, 2, 3}}, |
| 2341 | {"[1, 2, 3][99:]", []any{}}, |
| 2342 | {"[1, 2, 3][:-99]", []any{}}, |
| 2343 | {"[1, 2, 3][-99:]", []any{1, 2, 3}}, |
| 2344 | } |
| 2345 | |
| 2346 | for _, tt := range tests { |
| 2347 | t.Run(tt.code, func(t *testing.T) { |
| 2348 | got, err := expr.Eval(tt.code, nil) |
| 2349 | require.NoError(t, err, "eval error: "+tt.code) |
| 2350 | assert.Equal(t, tt.want, got, "eval: "+tt.code) |
| 2351 | }) |
| 2352 | } |
| 2353 | } |
| 2354 | |
| 2355 | func TestExpr_timeout(t *testing.T) { |
| 2356 | tests := []struct{ code string }{ |