@@ -115,4 +115,34 @@ public function testCount(): void
115115
116116 self ::assertEquals (1 , Set::of ('munus ' , 'is ' , 'awesome ' )->count (function (string $ value ) {return strpos ($ value , 'some ' ) !== false ; }));
117117 }
118+
119+ public function testAnyMatch (): void
120+ {
121+ self ::assertTrue (GenericList::of (1 , 2 , 3 , 4 , 5 )->anyMatch (fn (int $ v ) => $ v === 1 ));
122+ self ::assertTrue (GenericList::of (1 , 2 , 3 , 4 , 5 )->anyMatch (fn (int $ v ) => $ v === 3 ));
123+ self ::assertTrue (GenericList::of (1 , 2 , 3 , 4 , 5 )->anyMatch (fn (int $ v ) => $ v === 5 ));
124+
125+ self ::assertFalse (GenericList::of (1 , 2 , 3 , 4 , 5 )->anyMatch (fn (int $ v ) => $ v === 0 ));
126+ self ::assertFalse (GenericList::empty ()->anyMatch (fn (int $ v ) => $ v === 0 ));
127+ }
128+
129+ public function testAllMatch (): void
130+ {
131+ self ::assertTrue (GenericList::of (2 , 4 , 6 , 8 )->allMatch (fn (int $ v ) => $ v % 2 === 0 ));
132+ self ::assertTrue (GenericList::of (10 , 12 , 14 , 16 )->allMatch (fn (int $ v ) => $ v % 2 === 0 ));
133+ self ::assertTrue (GenericList::empty ()->allMatch (fn (int $ v ) => $ v % 2 === 1 ));
134+
135+ self ::assertFalse (GenericList::of (2 , 4 , 6 , 8 )->allMatch (fn (int $ v ) => $ v % 2 === 1 ));
136+ self ::assertFalse (GenericList::of (0 )->allMatch (fn (int $ v ) => $ v % 2 === 1 ));
137+ }
138+
139+ public function testNoneMatch (): void
140+ {
141+ self ::assertTrue (GenericList::of (2 , 4 , 6 , 8 )->noneMatch (fn (int $ v ) => $ v % 2 === 1 ));
142+ self ::assertTrue (GenericList::empty ()->noneMatch (fn (int $ v ) => $ v % 2 === 1 ));
143+
144+ self ::assertFalse (GenericList::of (2 , 4 , 6 , 8 )->noneMatch (fn (int $ v ) => $ v % 2 === 0 ));
145+ self ::assertFalse (GenericList::of (1 , 2 , 3 )->noneMatch (fn (int $ v ) => $ v % 2 === 0 ));
146+ self ::assertFalse (GenericList::of (1 )->noneMatch (fn (int $ v ) => $ v % 2 === 1 ));
147+ }
118148}
0 commit comments