File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/Runtime/Functions/Collection Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1313use function Fp \Collection \traverseEither ;
1414use function Fp \Collection \traverseEitherAcc ;
1515use function Fp \Collection \traverseEitherKV ;
16+ use function Fp \Collection \traverseEitherMerged ;
1617
1718final class EitherTraverseTest extends TestCase
1819{
@@ -36,6 +37,26 @@ public function testTraverse(): void
3637 );
3738 }
3839
40+ public function testTraverseEitherMerged (): void
41+ {
42+ /** @psalm-var list<int> $c */
43+ $ c = [1 , 2 , 3 , 4 ];
44+
45+ $ this ->assertEquals (
46+ Either::right ($ c ),
47+ traverseEitherMerged ($ c , fn (int $ v ) => $ v < 5
48+ ? Either::right ($ v )
49+ : Either::left (["{$ v } is too high " ]))
50+ );
51+
52+ $ this ->assertEquals (
53+ Either::left (['3 is too high ' , '4 is too high ' ]),
54+ traverseEitherMerged ($ c , fn (int $ v ) => $ v < 3
55+ ? Either::right ($ v )
56+ : Either::left (["{$ v } is too high " ]))
57+ );
58+ }
59+
3960 public function testTraverseAcc (): void
4061 {
4162 /** @psalm-var list<int> $c */
You can’t perform that action at this time.
0 commit comments