Example #1
0
 /**
  * This method tests the "replace" method.
  *
  * @dataProvider data_replace
  */
 public function test_replace(array $provided, array $expected)
 {
     $p0 = IRegex\Module::replace(IRegex\Type::box($provided[0]), ITuple\Type::box(array_map(function (string $item) : IString\Type {
         return IString\Type::box($item);
     }, $provided[1])));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IString\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
Example #2
0
 /**
  * This method tests the "covariant" method.
  *
  * @dataProvider data_covariant
  */
 public function test_covariant(array $provided, array $expected)
 {
     $p0 = ITuple\Type::covariant(ITuple\Type::box(array_map(function ($item) {
         return IObject\Type::box($item);
     }, $provided[0])));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\ITuple\\Type', $p0);
     $this->assertSame($e0, $p0->unbox(1));
 }
Example #3
0
 /**
  * This method returns a value as a boxed object.  A value is typically a PHP typed
  * primitive or object.  It is considered "not" type-safe.
  *
  * @access public
  * @static
  * @param mixed ...$xs                                      the value(s) to be boxed
  * @return ITuple\Type                                      the boxed object
  */
 public static function box2(...$xs) : ITuple\Type
 {
     return ITuple\Type::box($xs);
 }
Example #4
0
 /**
  * This method tests the "sequence" method.
  *
  * @dataProvider data_sequence
  */
 public function test_sequence(array $provided, array $expected)
 {
     if (is_array($provided[1])) {
         $p0 = IInt32\Module::sequence(IInt32\Type::box($provided[0]), ITuple\Type::box(array_map(function (int $item) : IInt32\Type {
             return IInt32\Type::box($item);
         }, $provided[1])));
         $e0 = $expected[0];
     } else {
         $p0 = IInt32\Module::sequence(IInt32\Type::box($provided[0]), IInt32\Type::box($provided[1]));
         $e0 = $expected[0];
     }
     $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $p0);
     $this->assertEquals($e0, $p0->unbox(1));
 }