| 36 | } |
| 37 | |
| 38 | func TestBefore(t *testing.T) { |
| 39 | t.Parallel() |
| 40 | |
| 41 | assert := internal.NewAssert(t, "TestBefore") |
| 42 | |
| 43 | arr := []string{"a", "b", "c", "d", "e"} |
| 44 | f := Before(3, func(i int) int { |
| 45 | return i |
| 46 | }) |
| 47 | |
| 48 | var res []int64 |
| 49 | type cb func(args ...any) []reflect.Value |
| 50 | appendStr := func(i int, _ string, fn cb) { |
| 51 | v := fn(i) |
| 52 | res = append(res, v[0].Int()) |
| 53 | } |
| 54 | |
| 55 | for i := 0; i < len(arr); i++ { |
| 56 | appendStr(i, arr[i], f) |
| 57 | } |
| 58 | |
| 59 | expected := []int64{0, 1, 2, 2, 2} |
| 60 | assert.Equal(expected, res) |
| 61 | } |
| 62 | |
| 63 | func TestCurry(t *testing.T) { |
| 64 | t.Parallel() |