Skip to content

Commit

Permalink
Merge 6c5ce22 into c7b561d
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Oct 21, 2018
2 parents c7b561d + 6c5ce22 commit eabe052
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,7 @@ language: php
php:
- 7.1
- 7.2
- 7.3
- nightly

matrix:
Expand Down
20 changes: 17 additions & 3 deletions tests/EagerWithArraysTest.php
Expand Up @@ -30,6 +30,12 @@
*/
class EagerWithArraysTest extends TestCase
{
public static function specimens(): \Generator
{
yield 'take' => [take([0, 0, 1, 2, 3])];
yield 'fromArray' => [fromArray([0, 0, 1, 2, 3])];
}

/**
* @dataProvider specimens
*/
Expand Down Expand Up @@ -72,9 +78,17 @@ public function testEagerArrayFilterAndReduce(Standard $pipeline)
$this->assertSame(6, $pipeline->filter()->reduce());
}

public static function specimens(): \Generator
/**
* @dataProvider specimens
*/
public function testNonEagerArrayMap(Standard $pipeline)
{
yield 'take' => [take([0, 0, 1, 2, 3])];
yield 'fromArray' => [fromArray([0, 0, 1, 2, 3])];
$this->assertSame([1, 1, 1, 1, 1], $pipeline->map(function ($value) {
return 1;
})->toArray());

// This should not be possible even with an array, as map() is always lazy
$this->expectExceptionMessage('Cannot traverse an already closed generator');
$pipeline->toArray();
}
}

0 comments on commit eabe052

Please sign in to comment.