コード例 #1
0
ファイル: foldTest.php プロジェクト: rkgladson/PHPixme
 public function scenarioProvider()
 {
     $add = function ($a, $b) {
         return $a + $b;
     };
     return ['add simple empty array' => [[], 0, $add, 0], 'add simple S[]' => [P\Seq::of(), 0, $add, 0], 'add simple None' => [P\None(), 0, $add, 0], 'ArrayObject[]' => [new \ArrayObject([]), 0, $add, 0], 'ArrayIterator[]' => [new \ArrayIterator([]), 0, $add, 0], 'add 1+2+3' => [[1, 2, 3], 0, $add, 6], 'add S[1,2,3]' => [P\Seq::of(1, 2, 3), 0, $add, 6], 'Some(2)+2' => [P\Some(2), 2, $add, 4], 'add ArrayObject[1,2,3]' => [new \ArrayObject([1, 2, 3]), 0, $add, 6], 'add ArrayIterator[1,2,3]' => [new \ArrayIterator([1, 2, 3]), 0, $add, 6]];
 }
コード例 #2
0
ファイル: reduceRightTest.php プロジェクト: rkgladson/PHPixme
 public function scenarioProvider()
 {
     $add = function ($a, $b) {
         return $a + $b;
     };
     return ['add 1' => [[1], $add, 1], 'add S[1]' => [P\Seq::of(1), $add, 1], 'add ArrayObject[1]' => [new \ArrayObject([1]), $add, 1], 'add ArrayIterator[1]' => [new \ArrayIterator([1]), $add, 1], 'add Some(2)' => [P\Some(2), $add, 2], 'add 1+2+3' => [[1, 2, 3], $add, 6], 'add S[1,2,3]' => [P\Seq::of(1, 2, 3), $add, 6], 'add ArrayObject[1,2,3]' => [new \ArrayObject([1, 2, 3]), $add, 6], 'add ArrayIterator[1,2,3]' => [new \ArrayIterator([1, 2, 3]), $add, 6]];
 }
コード例 #3
0
 public function scenarioProvider()
 {
     //$arrayLike, $hof, $expected
     $m2 = function ($value) {
         return $value % 2 === 0;
     };
     return ['[1,2,3] % 2' => [[1, 2, 3], $m2, ["false" => [[0, 1], [2, 3]], "true" => [[1, 2]]]], 'ArrayObject[1,2,3] % 2' => [new \ArrayObject([1, 2, 3]), $m2, ["false" => [[0, 1], [2, 3]], "true" => [[1, 2]]]], 'ArrayIterator[1,2,3] % 2' => [new \ArrayIterator([1, 2, 3]), $m2, ["false" => [[0, 1], [2, 3]], "true" => [[1, 2]]]], 'Some(1) % 2' => [P\Some(1), $m2, ["false" => [[0, 1]], "true" => []]], 'None % 2' => [P\None(), $m2, ["false" => [], "true" => []]], 'S[1,2,3] % 2' => [P\Seq::of(1, 2, 3), $m2, P\Seq::from(["false" => P\Seq::of([0, 1], [2, 3]), "true" => P\Seq::of([1, 2])])]];
 }
コード例 #4
0
ファイル: mapTest.php プロジェクト: rkgladson/PHPixme
 public function scenarioProvider()
 {
     $x2 = function ($value) {
         return $value * 2;
     };
     return ['[1,2] * 2' => [[1, 2], $x2, [2, 4]], 'ArrayObject[1,2] * 2' => [new \ArrayObject([1, 2]), $x2, [2, 4]], 'ArrayIterator[1,2] * 2' => [new \ArrayIterator([1, 2]), $x2, [2, 4]], 'S[1,2] * 2' => [P\Seq::of(1, 2), $x2, P\Seq::of(2, 4)], 'Some(1) *2' => [P\Some(1), $x2, P\Some(2)], 'None * 2' => [P\None(), $x2, P\None()], '[1,2,3] to string' => [[1, 2, 3], function ($value, $key) {
         return "{$key} => {$value}";
     }, ['0 => 1', '1 => 2', '2 => 3']]];
 }
コード例 #5
0
ファイル: PotTest.php プロジェクト: rkgladson/PHPixme
 public function filledCollectionProvider()
 {
     return [[[1]], [[1, 2, 3]], [P\Some(1)], [new \ArrayIterator([1])]];
 }
コード例 #6
0
ファイル: SomeTest.php プロジェクト: rkgladson/PHPixme
 /**
  * @covers ::count
  */
 public function test_count($value = true)
 {
     $subject = testNew($value);
     self::assertEquals(1, count($subject));
     self::assertEquals(1, $subject->count());
 }
コード例 #7
0
ファイル: MaybeTest.php プロジェクト: rkgladson/PHPixme
 public function maybeSomethingProvider()
 {
     return [[0], [[]], [''], [P\None()], [false], [true], [1], [1.1], ['1'], [[1]], [new \stdClass()], [P\Some('')]];
 }
コード例 #8
0
ファイル: NoneTest.php プロジェクト: rkgladson/PHPixme
 /**
  * @covers ::apply
  */
 public function test_apply()
 {
     $subject = testNew();
     self::assertSame($subject, $subject->apply(P\Some(null)));
 }
コード例 #9
0
ファイル: SeqTest.php プロジェクト: rkgladson/PHPixme
 public function indexOfProvider()
 {
     $none = P\None();
     $some1 = P\Some(1);
     $one = 1;
     return ['keyed source find None S[one=>1, none=>None, some=>Some(1) ]' => [testSubject::from(['one' => $one, 'none' => $none, 'some' => $some1]), $none, P\Some('none')], 'source find None S[1,None, Some(1)]' => [testSubject::of($one, $none, $some1), $none, P\Some(1)], 'source find Some(1) in S[1,2,Some(1),3]' => [testSubject::of(1, 2, $some1, 3), $some1, P\Some(2)], 'find null in 0 index' => [testSubject::from([null]), null, P\Some(0)], 'fail to find Some(1) in S[1,2,3]' => [testSubject::of(1, 2, 3), $some1, $none], 'fail to find Some(1) in S[]' => [testSubject::of(), $some1, $none]];
 }