diff --git a/cover.cov b/cover.cov index 97dfca1..14454bc 100644 --- a/cover.cov +++ b/cover.cov @@ -46,6 +46,10 @@ github.com/koss-null/funcfrog/internal/primitive/pointer/pointer.go:3.24,5.2 1 1 github.com/koss-null/funcfrog/internal/primitive/pointer/pointer.go:7.32,8.14 1 1 github.com/koss-null/funcfrog/internal/primitive/pointer/pointer.go:8.14,10.3 1 1 github.com/koss-null/funcfrog/internal/primitive/pointer/pointer.go:11.2,11.11 1 1 +github.com/koss-null/funcfrog/pkg/ff/compose.go:4.76,5.23 1 1 +github.com/koss-null/funcfrog/pkg/ff/compose.go:5.23,7.3 1 1 +github.com/koss-null/funcfrog/pkg/ff/map.go:6.73,8.2 1 1 +github.com/koss-null/funcfrog/pkg/ff/reduce.go:6.93,8.2 1 1 github.com/koss-null/funcfrog/pkg/pipies/comparators.go:9.48,11.2 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:17.31,19.2 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:22.30,24.2 1 1 @@ -56,12 +60,12 @@ github.com/koss-null/funcfrog/pkg/pipies/filters.go:42.49,43.25 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:43.25,45.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:49.61,50.25 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:50.25,52.3 1 1 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:59.75,63.25 3 0 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:63.25,64.15 1 0 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:59.75,63.25 3 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:63.25,64.15 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:64.15,66.4 1 0 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:67.3,72.28 4 0 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:72.28,74.4 1 0 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:75.3,76.14 2 0 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:67.3,72.28 4 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:72.28,74.4 1 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:75.3,76.14 2 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:7.49,8.24 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:8.24,10.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:14.67,15.31 1 1 @@ -69,6 +73,270 @@ github.com/koss-null/funcfrog/pkg/pipies/not.go:15.31,17.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:21.82,22.37 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:22.37,24.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/reducers.go:9.72,12.2 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:7.75,10.54 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:10.54,11.37 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:11.37,13.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:15.2,15.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:19.27,22.26 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:22.26,24.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:26.2,27.12 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:27.12,29.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:30.2,38.13 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:38.13,40.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:42.2,42.25 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:42.25,43.10 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:44.15,45.10 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:46.11,48.14 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:52.2,52.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:52.12,54.59 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:54.59,57.24 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:57.24,58.18 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:58.18,61.6 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:64.5,65.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:65.15,67.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:68.5,68.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:68.30,69.13 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:70.18,71.13 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:72.14,74.19 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:74.19,77.8 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:83.3,83.13 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:83.13,86.4 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/any.go:89.2,89.14 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:12.35,17.30 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:17.30,18.22 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:18.22,20.5 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:21.4,21.26 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:29.52,31.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:31.30,34.4 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:41.54,48.2 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:50.34,51.17 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:51.17,52.45 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:52.45,54.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:57.2,57.36 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:57.36,59.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:62.86,63.21 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:63.21,65.29 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:65.29,67.5 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:74.2,75.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:75.30,78.4 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:85.40,86.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:86.12,88.29 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:88.29,90.5 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:97.2,98.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:98.30,101.4 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:15.27,16.18 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:16.18,19.3 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:20.2,21.12 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:25.35,26.19 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:26.19,28.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:30.2,30.16 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:30.16,32.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:34.2,35.39 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:35.39,37.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:37.15,39.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:41.3,41.23 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:41.23,42.32 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:45.2,45.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:49.50,50.16 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:50.16,52.3 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:54.2,61.29 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:61.29,63.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:64.2,65.45 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:65.45,68.23 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:68.23,69.14 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:69.14,71.5 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:72.4,74.29 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:74.29,76.16 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:76.16,78.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:79.5,79.19 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:79.19,84.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:86.4,88.13 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:91.2,94.22 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:94.22,95.23 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:95.23,97.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/do.go:99.2,99.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/erase.go:3.36,5.32 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/erase.go:5.32,6.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/erase.go:6.41,9.5 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/erase.go:10.4,10.20 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:4.51,6.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:6.30,7.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:7.41,8.17 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:8.17,10.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:11.5,11.22 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/filter.go:13.4,13.20 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:9.29,11.26 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:11.26,13.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:14.2,14.44 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:17.72,20.29 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:20.29,22.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:22.15,24.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:26.2,26.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:42.60,53.2 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:55.51,59.30 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:59.30,63.3 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:64.2,64.19 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:64.19,67.3 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:70.45,77.30 4 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:77.30,79.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:79.10,81.34 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:81.34,85.5 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:87.4,87.36 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:91.2,91.38 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:91.38,94.3 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:97.72,98.16 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:98.16,100.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:101.2,107.45 5 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:107.45,109.32 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:109.32,110.17 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:110.17,112.5 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:114.4,115.29 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:115.29,116.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:117.17,118.12 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:119.13,121.18 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:121.18,124.7 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:127.4,127.25 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:129.3,129.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/first.go:132.2,132.25 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/map.go:5.44,7.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/map.go:7.30,8.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/map.go:8.41,11.5 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/map.go:12.4,12.20 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/mapfilter.go:6.58,8.30 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/mapfilter.go:8.30,9.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/mapfilter.go:9.41,12.5 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/mapfilter.go:13.4,13.20 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:26.45,27.53 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:27.53,29.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:30.2,31.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:36.38,37.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:37.41,39.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:40.2,41.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:46.37,47.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:47.41,49.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:50.2,51.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:55.30,56.18 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:56.18,58.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:59.2,60.12 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:64.31,65.9 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:66.18,67.15 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:68.20,69.18 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:70.10,71.25 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:75.33,77.2 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:79.35,81.2 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:83.43,84.11 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:84.11,86.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:87.2,87.10 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:90.43,91.11 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:91.11,93.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:94.2,94.10 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:97.26,99.2 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:101.38,104.25 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:104.25,106.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:107.2,107.16 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:3.48,7.29 4 1 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:7.29,9.31 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:9.31,11.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:11.15,13.5 1 0 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:14.4,14.21 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/promices.go:17.2,17.14 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:6.43,8.19 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:9.9,10.13 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:11.9,12.18 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:13.10,15.32 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:15.32,17.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/reduce.go:18.3,18.14 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:4.45,5.16 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:5.16,7.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:9.2,10.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:22.43,24.16 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:24.16,26.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/snag.go:27.2,28.10 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:10.55,15.30 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:15.30,16.19 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:16.19,18.23 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:18.23,20.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:21.5,21.53 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:23.4,23.24 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:23.24,25.5 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sort.go:26.4,26.28 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:5.79,10.24 5 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:10.24,12.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:12.15,15.9 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:19.2,19.24 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:19.24,21.15 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:21.15,23.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:25.2,25.12 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:29.41,31.26 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:31.26,33.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:35.2,43.20 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:43.20,47.3 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:49.2,50.39 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:50.39,53.23 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:53.23,57.29 4 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:57.29,58.41 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:58.41,60.6 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:62.4,64.25 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/sum.go:67.2,69.12 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:18.22,28.2 2 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:30.32,34.2 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:36.41,40.2 3 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:42.25,46.35 4 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:46.35,48.3 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:50.2,55.29 5 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:55.29,56.37 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:56.37,58.4 1 1 +github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:62.33,66.2 3 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:12.69,13.19 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:13.19,15.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.2,16.17 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.17,18.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.2,19.18 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.18,20.40 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:20.40,22.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:23.3,23.14 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:26.2,30.13 5 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:39.3,41.14 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:41.14,43.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:45.2,46.15 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:46.15,46.40 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.2,48.38 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.38,49.49 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:49.49,51.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:53.3,53.9 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:56.2,59.44 4 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:62.73,66.16 3 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:67.9,68.50 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:69.9,70.50 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.2,73.15 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.15,74.28 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:74.28,76.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.3,77.28 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.28,79.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.3,80.15 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.15,81.9 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:83.3,85.7 3 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:88.2,88.11 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:92.68,93.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:93.62,95.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.2,96.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.62,98.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.2,100.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.62,102.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.2,103.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.62,105.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.2,107.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.62,109.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.2,110.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.62,112.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.2,115.64 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.64,117.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.2,118.64 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.64,120.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:121.2,121.21 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:124.38,126.25 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:126.25,128.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:129.2,129.16 1 1 github.com/koss-null/funcfrog/pkg/pipe/collectors.go:6.50,9.33 2 0 github.com/koss-null/funcfrog/pkg/pipe/collectors.go:9.33,10.42 1 0 github.com/koss-null/funcfrog/pkg/pipe/collectors.go:10.42,13.5 2 0 @@ -93,17 +361,17 @@ github.com/koss-null/funcfrog/pkg/pipe/functype.go:37.53,38.28 1 0 github.com/koss-null/funcfrog/pkg/pipe/functype.go:38.28,40.3 1 0 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:15.46,17.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:20.52,22.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:27.60,29.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:27.60,29.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:32.53,34.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:38.42,40.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:43.40,45.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:48.30,50.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:53.28,55.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:53.28,55.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:59.47,61.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:64.28,66.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:69.31,71.2 1 0 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:75.49,77.2 1 0 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:81.38,83.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:69.31,71.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:75.49,77.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:81.38,83.2 1 1 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:86.48,88.2 1 0 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:91.58,93.2 1 0 github.com/koss-null/funcfrog/pkg/pipe/pipe.go:96.52,98.2 1 1 @@ -136,53 +404,3 @@ github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:62.10,64.27 2 0 github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:64.27,66.4 1 0 github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:67.3,67.13 1 0 github.com/koss-null/funcfrog/pkg/pipe/yeet.go:13.38,15.2 1 0 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:12.69,13.19 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:13.19,15.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.2,16.17 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.17,18.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.2,19.18 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.18,20.40 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:20.40,22.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:23.3,23.14 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:26.2,30.13 5 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:39.3,41.14 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:41.14,43.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:45.2,46.15 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:46.15,46.40 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.2,48.38 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.38,49.49 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:49.49,51.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:53.3,53.9 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:56.2,59.44 4 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:62.73,66.16 3 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:67.9,68.50 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:69.9,70.50 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.2,73.15 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.15,74.28 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:74.28,76.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.3,77.28 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.28,79.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.3,80.15 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.15,81.9 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:83.3,85.7 3 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:88.2,88.11 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:92.68,93.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:93.62,95.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.2,96.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.62,98.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.2,100.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.62,102.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.2,103.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.62,105.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.2,107.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.62,109.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.2,110.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.62,112.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.2,115.64 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.64,117.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.2,118.64 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.64,120.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:121.2,121.21 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:124.38,126.25 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:126.25,128.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:129.2,129.16 1 1 diff --git a/coverage_badge.png b/coverage_badge.png index 1e2e77a..fd9dc37 100644 Binary files a/coverage_badge.png and b/coverage_badge.png differ diff --git a/pkg/pipe/pipe_test.go b/pkg/pipe/pipe_test.go index 511f548..d8c446f 100644 --- a/pkg/pipe/pipe_test.go +++ b/pkg/pipe/pipe_test.go @@ -1,6 +1,7 @@ package pipe_test import ( + "errors" "os" "strconv" "strings" @@ -228,61 +229,6 @@ func TestMap(t *testing.T) { } } -func TestFirst(t *testing.T) { - t.Parallel() - - const limit = 100_000 - - testCases := []struct { - name string - function func() *float64 - expectedFirst float64 - }{ - { - name: "Slice_First_Filtered", - function: func() *float64 { - return ff.Map(largeSlice(), func(x int) float64 { - return float64(x) - }). - Filter(func(x *float64) bool { return *x > limit }). - First() - }, - expectedFirst: float64(100489), - }, - { - name: "Func_First_Limited", - function: func() *float64 { - return pipe.Func(func(i int) (float64, bool) { return float64(i), true }). - Filter(func(x *float64) bool { return *x > 10_000 }). - Take(limit). - First() - }, - expectedFirst: 10001, - }, - { - name: "Func_First_No_Limit", - function: func() *float64 { - return pipe.Fn(func(i int) float64 { return float64(i) }). - Filter(func(x *float64) bool { return *x > limit }). - First() - }, - expectedFirst: float64(limit) + 1.0, - }, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - t.Parallel() - - s := tc.function() - - require.NotNil(t, s) - require.Equal(t, tc.expectedFirst, *s) - }) - } -} - func TestFilter(t *testing.T) { t.Parallel() @@ -298,8 +244,7 @@ func TestFilter(t *testing.T) { Filter(pipies.NotNil[*float64]). Take(10_000), pointer.From[float64], - ). - Sum(pipies.Sum[float64]) + ).Sum(pipies.Sum[float64]) require.NotNil(t, s) sm := 0 @@ -311,34 +256,45 @@ func TestFilter(t *testing.T) { require.Equal(t, float64(sm), s) } -func TestReduce(t *testing.T) { +func TestMapFilter(t *testing.T) { t.Parallel() - res := pipe.Func(func(i int) (int, bool) { - return i, true - }). - Gen(6000). - Reduce(func(a, b *int) int { return *a + *b }) - - expected := 0 - for i := 1; i < 6000; i++ { - expected += i + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect []int + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p.MapFilter(func(x int) (int, bool) { + return x * 3, x%2 == 0 + }) + }, + expect: []int{6, 12, 18, 24, 0}, + }, } - require.Equal(t, expected, *res) -} -func TestSum(t *testing.T) { - res := pipe.Func(func(i int) (int, bool) { - return i, true - }). - Gen(6000). - Sum(func(a, b *int) int { return *a + *b }) + for _, c := range cases { + c := c + t.Run(c.name, func(t *testing.T) { + t.Parallel() - expected := 0 - for i := 1; i < 6000; i++ { - expected += i + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + res := p.Do() + require.Equal(t, c.expect, res) + }) } - require.Equal(t, expected, res) } func TestSort(t *testing.T) { @@ -417,6 +373,420 @@ func TestSort(t *testing.T) { } } +func TestReduce(t *testing.T) { + t.Parallel() + + res := pipe.Func(func(i int) (int, bool) { + return i, true + }). + Gen(6000). + Reduce(func(a, b *int) int { return *a + *b }) + + expected := 0 + for i := 1; i < 6000; i++ { + expected += i + } + require.Equal(t, expected, *res) +} + +func TestSum(t *testing.T) { + t.Parallel() + + res := pipe.Func(func(i int) (int, bool) { + return i, true + }). + Gen(6000). + Sum(func(a, b *int) int { return *a + *b }) + + expected := 0 + for i := 1; i < 6000; i++ { + expected += i + } + require.Equal(t, expected, res) +} + +func TestFirst(t *testing.T) { + t.Parallel() + + const limit = 100_000 + + testCases := []struct { + name string + function func() *float64 + expectedFirst float64 + }{ + { + name: "Slice_First_Filtered", + function: func() *float64 { + return ff.Map(largeSlice(), func(x int) float64 { + return float64(x) + }). + Filter(func(x *float64) bool { return *x > limit }). + First() + }, + expectedFirst: float64(100489), + }, + { + name: "Func_First_Limited", + function: func() *float64 { + return pipe.Func(func(i int) (float64, bool) { return float64(i), true }). + Filter(func(x *float64) bool { return *x > 10_000 }). + Take(limit). + First() + }, + expectedFirst: 10001, + }, + { + name: "Func_First_No_Limit", + function: func() *float64 { + return pipe.Fn(func(i int) float64 { return float64(i) }). + Filter(func(x *float64) bool { return *x > limit }). + First() + }, + expectedFirst: float64(limit) + 1.0, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + s := tc.function() + + require.NotNil(t, s) + require.Equal(t, tc.expectedFirst, *s) + }) + } +} + +func TestAny(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect []int + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + }, + } + + for _, c := range cases { + c := c + t.Run(c.name, func(t *testing.T) { + t.Parallel() + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + res := p.Any() + require.Contains(t, c.expect, *res) + }) + t.Run(c.name+"_parallel", func(t *testing.T) { + t.Parallel() + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + res := p.Parallel(7).Any() + require.Contains(t, c.expect, *res) + }) + } +} + +func TestCount(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect int + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: 10, + }, + { + name: "zero", + source: []int{}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: 0, + }, + { + name: "simple_fn", + funcSource: func(i int) (int, bool) { return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}[i], false }, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + take: 10, + expect: 10, + }, + { + name: "zero_fn", + funcSource: func(i int) (int, bool) { return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}[i], false }, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + take: 0, + expect: 0, + }, + } + + for _, c := range cases { + c := c + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + t.Run(c.name, func(t *testing.T) { + t.Parallel() + res := p.Count() + require.Equal(t, c.expect, res) + }) + t.Run(c.name+"_parallel", func(t *testing.T) { + t.Parallel() + res := p.Parallel(7).Count() + require.Equal(t, c.expect, res) + }) + } +} + +func TestPromices(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect []int + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + }, + { + name: "zero", + source: []int{}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: []int{}, + }, + } + + for _, c := range cases { + c := c + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + t.Run(c.name, func(t *testing.T) { + t.Parallel() + + res := p.Promices() + resAr := make([]int, len(res)) + for i := range res { + x, _ := res[i]() + resAr[i] = x + } + require.Equal(t, c.expect, resAr) + }) + t.Run(c.name+"_parallel", func(t *testing.T) { + t.Parallel() + + res := p.Parallel(7).Promices() + resAr := make([]int, len(res)) + for i := range res { + x, _ := res[i]() + resAr[i] = x + } + require.Equal(t, c.expect, resAr) + }) + } +} + +func TestErase(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect []int + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + }, + { + name: "zero", + source: []int{}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + return p + }, + expect: []int{}, + }, + } + + for _, c := range cases { + c := c + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + t.Run(c.name, func(t *testing.T) { + t.Parallel() + + res := p.Erase().Do() + resAr := make([]int, len(res)) + for i := range res { + resAr[i] = *(res[i].(*int)) + } + require.Equal(t, c.expect, resAr) + }) + t.Run(c.name+"_parallel", func(t *testing.T) { + t.Parallel() + + res := p.Erase().Parallel(7).Do() + resAr := make([]int, len(res)) + for i := range res { + resAr[i] = *(res[i].(*int)) + } + require.Equal(t, c.expect, resAr) + }) + } +} + +func TestYetiSnag(t *testing.T) { + t.Parallel() + + randErr := errors.New("test err") + simpleTestErr := errors.New("simple") + + mx := sync.Mutex{} + sharedCnt := 0 + shared := make(map[int]any) + + cases := []struct { + name string + source []int + take int + funcSource func(int) (int, bool) + apply func(pipe.Piper[int]) pipe.Piper[int] + expect func(*testing.T) + }{ + { + name: "simple", + source: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + apply: func(p pipe.Piper[int]) pipe.Piper[int] { + y := pipe.NewYeti() + return p. + Yeti(y). + Map(func(i int) int { + if i == 5 { + y.Yeet(errors.Join(simpleTestErr, randErr)) + } + return i + }). + Snag(func(e error) { + mx.Lock() + sharedCnt++ + shared[sharedCnt] = e + mx.Unlock() + }) + }, + expect: func(t *testing.T) { + mx.Lock() + defer mx.Unlock() + found := false + for _, v := range shared { + er := v.(error) + if errors.Is(er, simpleTestErr) { + found = true + break + } + } + require.True(t, found, "simple test case error was not found") + }, + }, + } + + for _, c := range cases { + c := c + + var p pipe.Piper[int] + if c.funcSource != nil { + p = c.apply(pipe.Func(c.funcSource).Take(c.take)) + } else { + p = c.apply(pipe.Slice(c.source)) + } + + t.Run(c.name, func(t *testing.T) { + t.Parallel() + + _ = p.Do() + c.expect(t) + }) + t.Run(c.name+"_parallel", func(t *testing.T) { + t.Parallel() + + _ = p.Parallel(7).Do() + c.expect(t) + }) + } +} + // helping functions func wrap[T any](x T) func() T {