Ejemplo n.º 1
0
 /**
  * This method tests the "nvl" method.
  */
 public function test_nvl()
 {
     $x = IInteger\Type::one();
     $y = IInteger\Type::zero();
     $z = IInteger\Module::nvl($x, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $z);
     $this->assertSame('1', $z->unbox());
     $z = IInteger\Module::nvl(null, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $z);
     $this->assertSame('1', $z->unbox());
     $z = IInteger\Module::nvl(null, null);
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $z);
     $this->assertSame('0', $z->unbox());
 }
Ejemplo n.º 2
0
 /**
  * This method returns the latter value should the former value evaluates
  * to null.
  *
  * @access public
  * @static
  * @param IInteger\Type $x                                  the value to be evaluated
  * @param IInteger\Type $y                                  the default value
  * @return IInteger\Type                                    the result
  */
 public static function nvl(IInteger\Type $x = null, IInteger\Type $y = null) : IInteger\Type
 {
     return $x ?? $y ?? IInteger\Type::zero();
 }
Ejemplo n.º 3
0
 /**
  * This method tests the "singletons" methods.
  */
 public function test_singletons()
 {
     $p0 = IInteger\Type::negative();
     $e0 = IInteger\Type::negative();
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $p0);
     $this->assertSame($e0->__hashCode(), $p0->__hashCode());
     $p1 = $p0->unbox();
     $e1 = '-1';
     $this->assertInternalType('string', $p1);
     $this->assertSame($e1, $p1);
     $p2 = IInteger\Type::zero();
     $e2 = IInteger\Type::zero();
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $p2);
     $this->assertSame($e2->__hashCode(), $p2->__hashCode());
     $p3 = $p2->unbox();
     $e3 = '0';
     $this->assertInternalType('string', $p3);
     $this->assertSame($e3, $p3);
     $p4 = IInteger\Type::one();
     $e4 = IInteger\Type::one();
     $this->assertInstanceOf('\\Saber\\Data\\IInteger\\Type', $p4);
     $this->assertSame($e4->__hashCode(), $p4->__hashCode());
     $p5 = $p4->unbox();
     $e5 = '1';
     $this->assertInternalType('string', $p5);
     $this->assertSame($e5, $p5);
 }