Exemplo n.º 1
0
 public function testFilter()
 {
     $predicate = Predicate(function ($value) {
         return $value % 2 === 0;
     });
     $this->assertTrue(Arrays::isArray(Repeatables::filter(self::getArray(), $predicate)));
     $this->assertTrue(Traversables::isTraversable(Repeatables::filter(self::getIterator(), $predicate)));
     $this->assertTrue(Traversables::isTraversable(Repeatables::filter(self::getIteratorAggregate(), $predicate)));
     $repeatables = [self::getArray(), self::getIterator(), self::getIteratorAggregate()];
     foreach ($repeatables as $repeatable) {
         foreach (Repeatables::filter($repeatable, $predicate) as $value) {
             $this->assertTrue($value % 2 === 0);
         }
     }
 }
Exemplo n.º 2
0
 public function testPredicate()
 {
     $this->assertEquals(Callables::newPredicate(self::get1Ary()), Predicate(self::get1Ary()));
     $this->assertEquals(Callables::newPredicate(self::get2Ary()), Predicate(self::get2Ary()));
     $this->assertEquals(Callables::newPredicate(self::get3Ary()), Predicate(self::get3Ary()));
 }