/** * This method tests the "nvl" method. */ public function test_nvl() { $x = IArrayList\Type::make(array(1, 2, 3), '\\Saber\\Data\\IInt32\\Type'); $y = IArrayList\Type::empty_(); $z = IArrayList\Module::nvl($x, $y); $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $z); $this->assertSame(array(1, 2, 3), $z->unbox(1)); $z = IArrayList\Module::nvl(null, $x); $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $z); $this->assertSame(array(1, 2, 3), $z->unbox(1)); $z = IArrayList\Module::nvl(null, null); $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $z); $this->assertSame(array(), $z->unbox(1)); }
/** * This method returns the either as an array. * * @access public * @final * @return IArrayList\Type the either as an array list */ public final function toArrayList() : IArrayList\Type { return $this->either->__isLeft() ? IArrayList\Type::box(array($this->either->item())) : IArrayList\Type::empty_(); }
/** * This method returns the latter value should the former value evaluates * to null. * * @access public * @static * @param IArrayList\Type $xs the value to be evaluated * @param IArrayList\Type $ys the default value * @return IArrayList\Type the result */ public static function nvl(IArrayList\Type $xs = null, IArrayList\Type $ys = null) : IArrayList\Type { return $xs ?? $ys ?? IArrayList\Type::empty_(); }
/** * This method tests the "empty" method. */ public function test_empty() { $p0 = IArrayList\Type::empty_(); $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $p0); $this->assertCount(0, $p0->unbox()); }
/** * This method returns the list as an array. * * @access public * @static * @param ILinkedList\Type $xs the operand * @return IArrayList\Type the list as an array list */ public static function toArrayList(ILinkedList\Type $xs) : IArrayList\Type { return ILinkedList\Module::foldLeft($xs, function (IArrayList\Type $c, Core\Type $x) { return IArrayList\Module::append($c, $x); }, IArrayList\Type::empty_()); }