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