Esempio n. 1
0
 /**
  * This method tests the "span" method.
  *
  * @dataProvider data_span
  */
 public function test_span(array $provided, array $expected)
 {
     $p0 = IArrayList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type');
     $p1 = $provided[1];
     $e0 = $expected[0];
     $e1 = $expected[1];
     $r0 = IArrayList\Module::span($p0, $p1);
     $this->assertInstanceOf('\\Saber\\Data\\ITuple\\Type', $r0);
     $v0 = $r0->first();
     $v1 = $r0->second();
     $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $v0);
     $this->assertSame($e0, $v0->unbox(1));
     $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $v1);
     $this->assertSame($e1, $v1->unbox(1));
 }
Esempio n. 2
0
 /**
  * This method returns a tuple where the first item contains longest prefix of the array
  * list that does not satisfy the predicate and the second item contains the remainder.
  *
  * @access public
  * @static
  * @param IArrayList\Type $xs                               the array list
  * @param callable $predicate                               the predicate function to be used
  * @return ITuple\Type                                      the tuple
  */
 public static function break_(IArrayList\Type $xs, callable $predicate) : ITuple\Type
 {
     return IArrayList\Module::span($xs, function (Core\Type $x, IInt32\Type $i) use($predicate) : IBool\Type {
         return IBool\Module::not($predicate($x, $i));
     });
 }