/**
  * This method tests the "or_" method.
  */
 public function test_or_()
 {
     $x = IBool\Type::true();
     $y = IBool\Type::false();
     $z = IBool\Module::or_($x, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(true, $z->unbox());
     $z = IBool\Module::or_($x, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(true, $z->unbox());
     $z = IBool\Module::or_($y, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(true, $z->unbox());
     $z = IBool\Module::or_($y, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(false, $z->unbox());
 }
Exemple #2
0
 /**
  * This method (aka "every" or "forall") iterates over the items in the collection, yielding each
  * item to the predicate function, or fails the truthy test.  Opposite of "none".
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param callable $predicate                               the predicate function to be used
  * @return IBool\Type                                       whether each item passed the
  *                                                          truthy test
  */
 public static function all(IOption\Type $xs, callable $predicate) : IBool\Type
 {
     return IBool\Module::or_(IBool\Module::not($xs->isDefined()), $predicate($xs->item(), IInt32\Type::zero()));
 }
Exemple #3
0
 /**
  * This method returns whether the ratio is a whole number.
  *
  * @access public
  * @static
  * @param IRatio\Type $x                                    the ratio to be evaluated
  * @return IBool\Type                                       whether the ratio is a whole
  *                                                          number
  */
 public static function isInteger(IRatio\Type $x) : IBool\Type
 {
     return IBool\Module::or_(IInt32\Module::eq($x->numerator(), IInt32\Type::zero()), IInt32\Module::eq($x->denominator(), IInt32\Type::one()));
 }