Beispiel #1
0
 /**
  * This method tests the "iterator" method.
  */
 public function test_iterator()
 {
     $p0 = IOption\Type::some(IInt32\Type::zero());
     $e0 = array(0);
     $this->assertInstanceOf('\\Saber\\Data\\IOption\\Some\\Type', $p0);
     $this->assertSame(count($e0), $p0->__size());
     $p1 = IOption\Module::iterator($p0);
     $e1 = 0;
     $this->assertInstanceOf('\\Saber\\Data\\IOption\\Iterator', $p1);
     foreach ($p1 as $i => $item) {
         $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $i);
         $this->assertSame($e1, $i->unbox());
         $this->assertInstanceOf('\\Saber\\Core\\Type', $item);
         $this->assertSame($e0[$e1], $item->unbox());
         $e1++;
     }
 }
Beispiel #2
0
 /**
  * This method returns the numerically lowest value.
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param IOption\Type $ys                                  the right operand
  * @return IOption\Type                                     the minimum value
  */
 public static function min(IOption\Type $xs, IOption\Type $ys) : IOption\Type
 {
     return IOption\Module::compare($xs, $ys)->unbox() <= 0 ? $xs : $ys;
 }
Beispiel #3
0
 /**
  * This method (aka "exists" and "some") returns whether some of the items in the string
  * passed the truthy test.
  *
  * @access public
  * @static
  * @param IString\Type $xs                                  the left operand
  * @param callable $predicate                               the predicate function to be used
  * @return IBool\Type                                       whether some of the items
  *                                                          passed the truthy test
  */
 public static function any(IString\Type $xs, callable $predicate) : IBool\Type
 {
     return IOption\Module::isDefined(IString\Module::find($xs, $predicate));
 }