/** * This method provides the data for testing the making of a boxed value. * * @return array */ public function data_singleton() { $data = array(array(array(IRatio\Type::one()), array(IInt32\Type::one(), IInt32\Type::one())), array(array(IRatio\Type::zero()), array(IInt32\Type::zero(), IInt32\Type::one())), array(array(IRatio\Type::negative()), array(IInt32\Type::negative(), IInt32\Type::one()))); return $data; }
/** * This method returns the index of the first occurrence that satisfies the predicate; otherwise, * it returns -1; * * @access public * @static * @param IString\Type $xs the left operand * @param callable $predicate the predicate function to be used * @return IInt32\Type the index of the first occurrence * or otherwise -1 */ public static function indexWhere(IString\Type $xs, callable $predicate) : IInt32\Type { $xi = IString\Module::iterator($xs); foreach ($xi as $i => $x) { if ($predicate($x, $i)->unbox()) { return $i; } } return IInt32\Type::negative(); }
/** * This method provides the data for testing that an item exists in the collection. * * @return array */ public function dataHasItem() { $data = array(array(array(IInt32\Type::zero()), array(true)), array(array(IInt32\Type::one()), array(true)), array(array(IInt32\Type::box(2)), array(true)), array(array(IInt32\Type::negative()), array(false))); return $data; }
/** * This method returns an object with a "-1" value. * * @access public * @static * @return IRatio\Type the object */ public static function negative() : IRatio\Type { if (!isset(static::$singletons[-1])) { static::$singletons[-1] = new IRatio\Type(IInt32\Type::negative(), IInt32\Type::one()); } return static::$singletons[-1]; }
/** * This method tests the "singletons" methods. */ public function test_singletons() { $p0 = IInt32\Type::negative(); $e0 = IInt32\Type::negative(); $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0); $this->assertSame($e0->__hashCode(), $p0->__hashCode()); $p1 = $p0->unbox(); $e1 = -1; $this->assertInternalType('integer', $p1); $this->assertSame($e1, $p1); $p2 = IInt32\Type::zero(); $e2 = IInt32\Type::zero(); $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p2); $this->assertSame($e2->__hashCode(), $p2->__hashCode()); $p3 = $p2->unbox(); $e3 = 0; $this->assertInternalType('integer', $p3); $this->assertSame($e3, $p3); $p4 = IInt32\Type::one(); $e4 = IInt32\Type::one(); $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p4); $this->assertSame($e4->__hashCode(), $p4->__hashCode()); $p5 = $p4->unbox(); $e5 = 1; $this->assertInternalType('integer', $p5); $this->assertSame($e5, $p5); }