diff --git a/cover.cov b/cover.cov index aa303b2..97dfca1 100644 --- a/cover.cov +++ b/cover.cov @@ -46,184 +46,143 @@ 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/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:10.35,14.30 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:14.30,15.22 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:15.22,17.5 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:18.4,18.26 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:26.52,28.30 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:28.30,31.4 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:38.54,45.2 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:47.34,48.17 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:48.17,49.45 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:49.45,51.4 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:54.2,54.36 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:54.36,56.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:59.86,60.21 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:60.21,62.29 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:62.29,64.5 1 0 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:70.2,71.30 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:71.30,74.4 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:81.40,82.12 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:82.12,84.29 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:84.29,86.5 1 0 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:92.2,93.30 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/constructor.go:93.30,96.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,31.39 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:31.39,33.15 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:33.15,35.4 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:37.3,37.23 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:37.23,38.32 1 0 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:41.2,41.12 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:45.50,53.29 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:53.29,55.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:56.2,57.45 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:57.45,60.23 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:60.23,61.14 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:61.14,63.5 1 0 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:64.4,66.29 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:66.29,68.16 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:68.16,70.6 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:71.5,71.19 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:71.19,76.6 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:78.4,80.13 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:83.2,86.22 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:86.22,87.23 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:87.23,89.4 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/do.go:91.2,91.41 1 1 -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 1 -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/pipe.go:24.45,25.53 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:25.53,27.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:28.2,29.10 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:34.38,35.41 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:35.41,37.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:38.2,39.10 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:44.37,45.41 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:45.41,47.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:48.2,49.10 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:53.30,54.18 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:54.18,56.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:57.2,58.12 2 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:62.31,63.9 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:64.18,65.15 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:66.20,67.18 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:68.10,69.25 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:73.33,75.2 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:77.35,79.2 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:81.43,82.11 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:82.11,84.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:85.2,85.10 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:88.43,89.11 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:89.11,91.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:92.2,92.10 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:95.26,97.2 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:99.38,102.25 3 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:102.25,104.3 1 1 -github.com/koss-null/funcfrog/internal/internalpipe/pipe.go:105.2,105.16 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/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/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 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:27.39,30.2 2 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:35.46,36.25 1 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:36.25,38.3 1 1 +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: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/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 +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/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 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:14.4,14.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:23.62,26.33 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:26.33,27.42 1 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:27.42,30.5 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:31.4,31.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:10.36,12.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:22.58,24.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:33.48,34.36 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:34.36,36.3 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:48.60,50.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:57.40,59.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:64.87,66.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:69.41,71.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:10.43,11.25 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:11.25,14.3 2 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:24.48,25.25 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:25.25,27.3 1 0 +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: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: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: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 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:15.53,17.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:20.59,22.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:27.67,29.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:32.32,34.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:37.30,39.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:43.42,45.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:49.41,51.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:55.54,57.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:61.45,63.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:66.55,68.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:71.65,73.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:76.54,78.2 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:13.15,16.33 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:16.33,17.42 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:17.42,20.5 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:21.4,21.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:33.20,36.33 2 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:36.33,37.42 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:37.42,40.5 2 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:41.4,41.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:51.98,53.22 2 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:53.22,55.3 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:56.2,57.19 2 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:58.9,59.14 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:60.9,61.29 1 0 +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/go.mod b/go.mod index 58e5eaa..6195548 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,17 @@ require ( golang.org/x/exp v0.0.0-20231006140011-7918f672742d ) +require ( + github.com/fatih/color v1.16.0 // indirect + github.com/fogleman/gg v1.3.0 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/jpoles1/gopherbadger v2.5.0+incompatible // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + golang.org/x/image v0.14.0 // indirect + golang.org/x/sys v0.14.0 // indirect +) + require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 24e57d6..7dd2709 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,19 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/jpoles1/gopherbadger v2.5.0+incompatible h1:yey2mSCoeWrPE/Q+6sz8CbJDjIRtx6wqc+DCf4VV4/A= +github.com/jpoles1/gopherbadger v2.5.0+incompatible/go.mod h1:DVwxsf5adYLiDOj955t/ejfCRWjKA5tme6Vejb72Ro0= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -8,8 +21,19 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +<<<<<<< HEAD golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +======= +golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b h1:SCE/18RnFsLrjydh/R/s5EVvHoZprqEQUuoxK8q2Pc4= +golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= +golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +>>>>>>> 7a99372 ([] refactoring tests) gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/internalpipe/mapfilterer_test.go b/internal/internalpipe/mapfilterer_test.go index 3187ab4..004c958 100644 --- a/internal/internalpipe/mapfilterer_test.go +++ b/internal/internalpipe/mapfilterer_test.go @@ -136,4 +136,37 @@ func Test_MapFilter(t *testing.T) { require.Equal(t, 0, len(res)) }) +<<<<<<< HEAD +======= + + t.Run("single thread ValLim set", func(t *testing.T) { + p := Pipe[int]{ + Fn: func(i int) (*int, bool) { + return &i, false + }, + Len: -1, + ValLim: len(exp), + GoroutinesCnt: 1, + } + res := p.MapFilter(func(x int) (int, bool) { return x + 1, true }). + Do() + + require.Equal(t, 0, len(res)) + }) + + t.Run("seven thread ValLim set", func(t *testing.T) { + p := Pipe[int]{ + Fn: func(i int) (*int, bool) { + return &i, false + }, + Len: -1, + ValLim: len(exp), + GoroutinesCnt: 7, + } + res := p.MapFilter(func(x int) (int, bool) { return x + 1, false }). + Do() + + require.Equal(t, 0, len(res)) + }) +>>>>>>> 7a99372 ([] refactoring tests) } diff --git a/pkg/pipe/pipe_test.go b/pkg/pipe/pipe_test.go new file mode 100644 index 0000000..511f548 --- /dev/null +++ b/pkg/pipe/pipe_test.go @@ -0,0 +1,486 @@ +package pipe_test + +import ( + "os" + "strconv" + "strings" + "sync" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/koss-null/funcfrog/internal/primitive/pointer" + "github.com/koss-null/funcfrog/pkg/ff" + "github.com/koss-null/funcfrog/pkg/pipe" + "github.com/koss-null/funcfrog/pkg/pipies" +) + +func TestSlice(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + testCase func() []int + expected func() []int + }{ + { + name: "simple", + testCase: func() []int { + return pipe.Slice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Do() + }, + expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), + }, + { + name: "large", + testCase: func() []int { + return pipe.Slice(largeSlice()).Do() + }, + expected: wrap(largeSlice()), + }, + { + name: "empty", + testCase: func() []int { + return pipe.Slice([]int{}).Do() + }, + expected: wrap([]int{}), + }, + { + name: "single element", + testCase: func() []int { + return pipe.Slice([]int{1}).Do() + }, + expected: wrap([]int{1}), + }, + { + name: "simple parallel 12", + testCase: func() []int { + return pipe.Slice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Parallel(10).Do() + }, + expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), + }, + { + name: "large parallel 12", + testCase: func() []int { + return pipe.Slice(largeSlice()).Parallel(12).Do() + }, + expected: wrap(largeSlice()), + }, + { + name: "empty parallel 12", + testCase: func() []int { + return pipe.Slice([]int{}).Parallel(12).Do() + }, + expected: wrap([]int{}), + }, + { + name: "single element parallel 12", + testCase: func() []int { + return pipe.Slice([]int{1}).Parallel(12).Do() + }, + expected: wrap([]int{1}), + }, + } + + for _, c := range cases { + c := c + t.Run(c.name, func(t *testing.T) { + t.Parallel() + require.Equal(t, c.expected(), c.testCase()) + }) + } +} + +func TestFunc(t *testing.T) { + t.Parallel() + ls := largeSlice() + + cases := []struct { + name string + testCase pipe.Piper[int] + expected func() []int + }{ + { + name: "Simple_gen", + testCase: pipe.Func(func(i int) (int, bool) { + return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}[i], true + }).Gen(10), + expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), + }, + { + name: "Large_gen", + testCase: pipe.Func(func(i int) (int, bool) { + return ls[i], true + }).Gen(len(ls)), + expected: wrap(largeSlice()), + }, + { + name: "Empty_gen", + testCase: pipe.Func(func(i int) (int, bool) { + return 0, false + }).Gen(0), + expected: wrap([]int{}), + }, + { + name: "Single_element_gen", + testCase: pipe.Func(func(i int) (int, bool) { + return 1, true + }).Gen(1), + expected: wrap([]int{1}), + }, + /////////TAKE + { + name: "Simple_take", + testCase: pipe.Func(func(i int) (int, bool) { + return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}[i], true + }).Take(10), + expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), + }, + { + name: "Large_take", + testCase: pipe.Func(func(i int) (int, bool) { + return ls[i], true + }).Take(len(ls)), + expected: wrap(largeSlice()), + }, + { + name: "Empty_take", + testCase: pipe.Func(func(i int) (int, bool) { + return 0, false + }).Take(0), + expected: wrap([]int{}), + }, + { + name: "Single_element_take", + testCase: pipe.Func(func(i int) (int, bool) { + return 1, true + }).Take(1), + expected: wrap([]int{1}), + }, + } + + for _, c := range cases { + c := c + t.Run(c.name, func(t *testing.T) { + t.Parallel() + require.Equal(t, c.expected(), c.testCase.Do()) + }) + t.Run(c.name+" parallel 12", func(t *testing.T) { + t.Parallel() + require.Equal(t, c.expected(), c.testCase.Do()) + }) + } +} + +func TestMap(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + input pipe.Piper[int] + f func(int) int + want []int + }{ + { + name: "Map_double", + input: pipe.Slice([]int{1, 2, 3}), + f: func(i int) int { return i * 2 }, + want: []int{2, 4, 6}, + }, + { + name: "Map_empty", + input: pipe.Slice([]int{}), + f: func(i int) int { return i }, + want: []int{}, + }, + { + name: "Map_single_element", + input: pipe.Slice([]int{1}), + f: func(i int) int { return i }, + want: []int{1}, + }, + { + name: "Map_many_diffeerent_elements", + input: pipe.Slice(largeSlice()), + f: func(x int) int { return x * 2 }, + want: func() []int { + b := make([]int, len(largeSlice())) + ls := largeSlice() + for i := range ls { + b[i] = ls[i] * 2 + } + return b + }(), + }, + } + + for _, c := range cases { + c := c + t.Run(c.name, func(t *testing.T) { + t.Parallel() + res := c.input.Map(c.f).Do() + require.Equal(t, c.want, res) + }) + t.Run(c.name+" parallel 12", func(t *testing.T) { + t.Parallel() + res := c.input.Map(c.f).Do() + require.Equal(t, c.want, 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 TestFilter(t *testing.T) { + t.Parallel() + + genFunc := func(i int) (*float64, bool) { + if i%10 == 0 { + return nil, true + } + return pointer.To(float64(i)), true + } + + s := pipe.Map( + pipe.Func(genFunc). + Filter(pipies.NotNil[*float64]). + Take(10_000), + pointer.From[float64], + ). + Sum(pipies.Sum[float64]) + require.NotNil(t, s) + + sm := 0 + for i := 1; i < 10000; i++ { + if i%10 != 0 { + sm += i + } + } + require.Equal(t, float64(sm), s) +} + +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) { + 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 TestSort(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + size int + parallel uint16 + }{ + { + name: "Simple", + size: 50_000, + parallel: 4, + }, + { + name: "Single_thread", + size: 400_000, + parallel: 1, + }, + { + name: "Single_thread_tiny", + size: 3, + parallel: 1, + }, + { + name: "Single_thread_empty", + size: 0, + parallel: 1, + }, + { + name: "MultiThread", + size: 400_000, + parallel: 8, + }, + { + name: "tiny", + size: 3, + parallel: 8, + }, + { + name: "one", + size: 1, + parallel: 8, + }, + { + name: "empty", + size: 0, + parallel: 8, + }, + { + name: "smallArray", + size: 6000, + parallel: 8, + }, + { + name: "Many_threads", + size: 6000, + parallel: 8000, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + a, err := readTestData() + require.Nil(t, err) + a = a[:tc.size] + res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(tc.parallel).Do() + for i := 0; i < len(res)-1; i++ { + require.LessOrEqual(t, res[i], res[i+1]) + } + }) + } +} + +// helping functions + +func wrap[T any](x T) func() T { + return func() T { + return x + } +} + +var ( + a []int + mx1 sync.Mutex + + pls pipe.Piper[int] + mx2 sync.Mutex + + testSlice []int + mxTestSlice sync.Mutex +) + +func largeSlice() []int { + const largeSize = 400_000 + mx1.Lock() + defer mx1.Unlock() + + if a == nil { + a = make([]int, largeSize) + for i := range a { + a[i] = i * i + } + } + return a +} + +func pipeLargeSlice() pipe.Piper[int] { + mx2.Lock() + defer mx2.Unlock() + + if pls == nil { + pls = pipe.Slice(largeSlice()) + } + + return pls +} + +func readTestData() ([]int, error) { + mxTestSlice.Lock() + defer mxTestSlice.Unlock() + if len(testSlice) != 0 { + return testSlice, nil + } + raw, err := os.ReadFile("../../.test_data/test1.txt") + if err != nil { + return nil, err + } + a := make([]int, 0) + for _, val := range strings.Split(string(raw), " ") { + val = strings.Trim(val, "][,") + ival, err := strconv.Atoi(val) + if err != nil { + return nil, err + } + a = append(a, ival) + } + + testSlice = a + return a, nil +} diff --git a/pkg/pipe/test/coverage_test.go b/pkg/pipe/test/coverage_test.go deleted file mode 100644 index f7fcfbf..0000000 --- a/pkg/pipe/test/coverage_test.go +++ /dev/null @@ -1,251 +0,0 @@ -package pipe_test - -import ( - "fmt" - "sync" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/koss-null/funcfrog/pkg/pipe" -) - -func wrap[T any](x T) func() T { - return func() T { - return x - } -} - -var ( - a []int - mx1 sync.Mutex -) - -func largeSlice() []int { - mx1.Lock() - defer mx1.Unlock() - - if a == nil { - a = make([]int, 1_000_000) - for i := range a { - a[i] = i * i - } - } - return a -} - -var ( - pls pipe.Piper[int] - mx2 sync.Mutex -) - -func pipeLargeSlice() pipe.Piper[int] { - mx2.Lock() - defer mx2.Unlock() - if pls == nil { - pls = pipe.Slice(largeSlice()) - } - return pls -} - -func TestScice(t *testing.T) { - cases := []struct { - name string - testCase func() []int - expected func() []int - }{ - { - name: "simple", - testCase: func() []int { - return pipe.Slice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Do() - }, - expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), - }, - { - name: "large", - testCase: func() []int { - return pipe.Slice(largeSlice()).Do() - }, - expected: wrap(largeSlice()), - }, - { - name: "empty", - testCase: func() []int { - return pipe.Slice([]int{}).Do() - }, - expected: wrap([]int{}), - }, - { - name: "single element", - testCase: func() []int { - return pipe.Slice([]int{1}).Do() - }, - expected: wrap([]int{1}), - }, - { - name: "simple parallel 12", - testCase: func() []int { - return pipe.Slice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Parallel(10).Do() - }, - expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), - }, - { - name: "large parallel 12", - testCase: func() []int { - return pipe.Slice(largeSlice()).Parallel(12).Do() - }, - expected: wrap(largeSlice()), - }, - { - name: "empty parallel 12", - testCase: func() []int { - return pipe.Slice([]int{}).Parallel(12).Do() - }, - expected: wrap([]int{}), - }, - { - name: "single element parallel 12", - testCase: func() []int { - return pipe.Slice([]int{1}).Parallel(12).Do() - }, - expected: wrap([]int{1}), - }, - } - - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - require.Equal(t, c.expected(), c.testCase()) - }) - } -} - -func TestFunc(t *testing.T) { - cases := []struct { - name string - testCase pipe.Piper[int] - expected func() []int - }{ - { - name: "simple gen", - testCase: pipe.Func(func(i int) (int, bool) { - return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}[i], true - }).Gen(10), - expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), - }, - { - name: "large gen", - testCase: pipe.Func(func(i int) (int, bool) { - return largeSlice()[i], true - }).Gen(len(largeSlice())), - expected: wrap(largeSlice()), - }, - { - name: "empty gen", - testCase: pipe.Func(func(i int) (int, bool) { - return 0, false - }).Gen(0), - expected: wrap([]int{}), - }, - { - name: "single element gen", - testCase: pipe.Func(func(i int) (int, bool) { - return 1, true - }).Gen(1), - expected: wrap([]int{1}), - }, - - { - name: "simple take", - testCase: pipe.Func(func(i int) (int, bool) { - return []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}[i], true - }).Take(10), - expected: wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), - }, - { - name: "large take", - testCase: pipe.Func(func(i int) (int, bool) { - return largeSlice()[i], true - }).Take(len(largeSlice())), - expected: wrap(largeSlice()), - }, - { - name: "empty take", - testCase: pipe.Func(func(i int) (int, bool) { - return 0, false - }).Take(0), - expected: wrap([]int{}), - }, - { - name: "single element take", - testCase: pipe.Func(func(i int) (int, bool) { - return 1, true - }).Take(1), - expected: wrap([]int{1}), - }, - } - - _ = pipe.Func(func(i int) (int, bool) { - return 0, false - }).Take(0) - for _, c := range cases { - fmt.Println(c.name) - t.Run(c.name, func(t *testing.T) { - require.Equal(t, c.expected(), c.testCase.Do()) - }) - t.Run(c.name+" parallel 12", func(t *testing.T) { - require.Equal(t, c.expected(), c.testCase.Do()) - }) - } -} - -func TestMap(t *testing.T) { - cases := []struct { - name string - input pipe.Piper[int] - f func(int) int - want []int - }{ - { - name: "map double", - input: pipe.Slice([]int{1, 2, 3}), - f: func(i int) int { return i * 2 }, - want: []int{2, 4, 6}, - }, - { - name: "map empty", - input: pipe.Slice([]int{}), - f: func(i int) int { return i }, - want: []int{}, - }, - { - name: "map single element", - input: pipe.Slice([]int{1}), - f: func(i int) int { return i }, - want: []int{1}, - }, - { - name: "map many diffeerent elements", - input: pipe.Slice(largeSlice()), - f: func(x int) int { return x * 2 }, - want: func() []int { - b := make([]int, len(largeSlice())) - ls := largeSlice() - for i := range ls { - b[i] = ls[i] * 2 - } - return b - }(), - }, - } - - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - res := c.input.Map(c.f).Do() - require.Equal(t, c.want, res) - }) - t.Run(c.name+" parallel 12", func(t *testing.T) { - res := c.input.Map(c.f).Do() - require.Equal(t, c.want, res) - }) - } -} diff --git a/pkg/pipe/test/pipe_sort_test.go b/pkg/pipe/test/pipe_sort_test.go deleted file mode 100644 index 382dc5e..0000000 --- a/pkg/pipe/test/pipe_sort_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package pipe_test - -import ( - "os" - "strconv" - "strings" - "sync" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/koss-null/funcfrog/pkg/pipe" - "github.com/koss-null/funcfrog/pkg/pipies" -) - -var ( - testSlice []int - mx sync.Mutex -) - -func readTestData() ([]int, error) { - mx.Lock() - defer mx.Unlock() - if len(testSlice) != 0 { - return testSlice, nil - } - raw, err := os.ReadFile("../../../.test_data/test1.txt") - if err != nil { - return nil, err - } - a := make([]int, 0) - for _, val := range strings.Split(string(raw), " ") { - val = strings.Trim(val, "][,") - ival, err := strconv.Atoi(val) - if err != nil { - return nil, err - } - a = append(a, ival) - } - - testSlice = a - return a, nil -} - -func Test_Sort(t *testing.T) { - a, err := readTestData() - require.Nil(t, err) - require.Equal(t, len(a), 1000000) - res := pipe.Slice(a).Sort(pipies.Less[int]).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} - -func Test_Sort_singleThread(t *testing.T) { - a, err := readTestData() - require.Nil(t, err) - require.Equal(t, len(a), 1000000) - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(1).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} - -func Test_Sort_multiThread(t *testing.T) { - a, err := readTestData() - require.Nil(t, err) - require.Equal(t, len(a), 1000000) - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} - -func Test_Sort_minArray(t *testing.T) { - a, err := readTestData() - require.Nil(t, err) - a = a[0:5001] - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} - -func Test_Sort_tiny(t *testing.T) { - a := []int{4, 2, 1} - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} - -func Test_Sort_one(t *testing.T) { - a := []int{1} - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - require.Equal(t, len(res), 1) - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) // does not run - } -} - -func Test_Sort_empty(t *testing.T) { - a := []int{} - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - require.Equal(t, len(res), 0) - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) // does not run - } -} - -func Test_Sort_smallArray(t *testing.T) { - a, err := readTestData() - require.Nil(t, err) - a = a[0:6000] - res := pipe.Slice(a).Sort(pipies.Less[int]).Parallel(8).Do() - for i := 0; i < len(res)-1; i++ { - require.LessOrEqual(t, res[i], res[i+1]) - } -} diff --git a/pkg/pipe/test/pipe_test.go b/pkg/pipe/test/pipe_test.go deleted file mode 100644 index f0ee9cf..0000000 --- a/pkg/pipe/test/pipe_test.go +++ /dev/null @@ -1,281 +0,0 @@ -package pipe_test - -import ( - "crypto/rand" - "math" - "math/big" - "sort" - "sync" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/koss-null/funcfrog/internal/primitive/pointer" - "github.com/koss-null/funcfrog/pkg/pipe" - "github.com/koss-null/funcfrog/pkg/pipies" -) - -var ( - once sync.Once - a1kk []float64 -) - -func initA1kk() { - once.Do(func() { - a1kk = make([]float64, 1_000_000) - for i := range a1kk { - a1kk[i] = float64(i) - } - }) -} - -var ( - randSrc []int - randMx sync.Mutex -) - -func randN(n int) []int { - randMx.Lock() - defer randMx.Unlock() - - if len(randSrc) != 0 { - dest := make([]int, n) - copy(dest, randSrc[:n]) - return dest - } - - result := make([]int, 10e8) - for i := 0; i < n; i++ { - nBig, err := rand.Int(rand.Reader, big.NewInt(10e8)) - if err != nil { - panic(err) - } - result[i] = int(nBig.Int64()) - } - - randSrc = result - dest := make([]int, n) - copy(dest, randSrc[:n]) - return dest -} - -func TestSlice_ok(t *testing.T) { - t.Parallel() - initA1kk() - - // Slice() function - t.Run("Slice() happy 100k slice", func(t *testing.T) { - a := make([]struct { - i int - f float64 - }, 100_000) - s := pipe.Slice(a).Do() - for i := range a { - require.Equal(t, a[i], s[i]) - } - }) - - t.Run("Slice() happy 1kk slice", func(t *testing.T) { - s := pipe.Slice(a1kk).Do() - for i := range a1kk { - require.Equal(t, a1kk[i], s[i]) - } - }) - - t.Run("Slice() happy struct slice", func(t *testing.T) { - a := make([]struct { - i int - f float64 - }, 100) - s := pipe.Slice(a).Do() - for i := range a { - require.Equal(t, a[i], s[i]) - } - }) - - // Map() function - t.Run("Map().Map() 1kk", func(t *testing.T) { - s := pipe.Slice(a1kk). - Parallel(4). - Map(func(x float64) float64 { return x * x * x }). - Map(math.Sqrt). - Do() - - for i := range a1kk { - aaa := float64(a1kk[i] * a1kk[i] * a1kk[i]) - require.Equal(t, math.Sqrt(aaa), s[i]) - } - }) - - // First() function - t.Run("Slice().First() happy", func(t *testing.T) { - s := pipe.Slice(a1kk). - Filter(func(x *float64) bool { return *x > 100_000 }). - First() - require.NotNil(t, s) - require.Equal(t, float64(100_001), *s) - }) - - t.Run("Func().First() happy", func(t *testing.T) { - s := pipe.Func(func(i int) (float64, bool) { return float64(i), true }). - Filter(func(x *float64) bool { return *x > 100_000 }). - Take(200_000). - First() - require.NotNil(t, s) - require.Equal(t, float64(100_001), *s) - }) - - t.Run("Func().First() happy no limit", func(t *testing.T) { - s := pipe.Fn(func(i int) float64 { return float64(i) }). - Filter(func(x *float64) bool { return *x > 100_000 }). - First() - require.NotNil(t, s) - require.Equal(t, float64(100_001), *s) - }) - - // Filter() function - t.Run("Func().Filter() happy remove nils", func(t *testing.T) { - }) -} - -func TestFilter_NotNull_ok(t *testing.T) { - genFunc := func(i int) (*float64, bool) { - if i%10 == 0 { - return nil, true - } - return pointer.To(float64(i)), true - } - - s := pipe.Map( - pipe.Func(genFunc). - Filter(pipies.NotNil[*float64]). - Take(10_000), - pointer.From[float64], - ). - Sum(pipies.Sum[float64]) - require.NotNil(t, s) - - sm := 0 - for i := 1; i < 10000; i++ { - if i%10 != 0 { - sm += i - } - } - require.Equal(t, float64(sm), s) -} - -// Sort() function - -func TestSort_ok_parallel1(t *testing.T) { - rnd := randN(100_000) - s := pipe.Func(func(i int) (float32, bool) { - return float32(rnd[i]), true - }). - Parallel(1). - Take(100_000). - Sort(pipies.Less[float32]). - Do() - - require.NotNil(t, s) - prevItem := s[0] - for _, item := range s { - require.GreaterOrEqual(t, item, prevItem) - } -} - -func TestSort_ok_parallel_default(t *testing.T) { - rnd := randN(100_000) - s := pipe.Func(func(i int) (float32, bool) { - return float32(rnd[i]), true - }). - Take(100_000). - Sort(pipies.Less[float32]). - Do() - - require.NotNil(t, s) - prevItem := s[0] - for _, item := range s { - require.GreaterOrEqual(t, item, prevItem) - } -} - -func TestSort_ok_parallel_slice(t *testing.T) { - a := make([]int, 6000) - rnd := randN(100_000) - for i := range a { - a[i] = int(rnd[i] * 100_000) - } - - s := pipe.Slice(a). - Sort(pipies.Less[int]). - Do() - - require.NotNil(t, s) - sort.Ints(a) - for i := range a { - require.Equal(t, s[i], a[i]) - } -} - -func TestSort_ok_parallel12(t *testing.T) { - rnd := randN(100_000) - s := pipe.Func(func(i int) (float32, bool) { - return float32(rnd[i]), true - }). - Parallel(12). - Take(100_000). - Sort(pipies.Less[float32]). - Do() - - require.NotNil(t, s) - prevItem := s[0] - for _, item := range s { - require.GreaterOrEqual(t, item, prevItem) - } -} - -func TestSort_ok_parallel_large(t *testing.T) { - largeNumber := 6_000_000 - rnd := randN(largeNumber) - s := pipe.Func(func(i int) (float32, bool) { - return float32(rnd[i]), true - }). - Parallel(12). - Take(largeNumber). - Sort(pipies.Less[float32]). - Do() - - require.NotNil(t, s) - prevItem := s[0] - for _, item := range s { - require.GreaterOrEqual(t, item, prevItem) - } -} - -func TestReduce(t *testing.T) { - 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) { - 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) -}