diff --git a/tests/Collections/LazyTest.php b/tests/Collections/LazyTest.php index 3897030..25dc805 100644 --- a/tests/Collections/LazyTest.php +++ b/tests/Collections/LazyTest.php @@ -65,17 +65,6 @@ class LazyTest extends \PHPUnit\Framework\TestCase $this->assertSame(6, $walked); } - public function testLazyChainWorksWithPipe() - { - $result = self::naturals() - |> lazy\map(static fn ($x) => $x * 2) - |> lazy\skip(1) - |> lazy\take(2) - |> c\toArray(); - - $this->assertSame([1 => 4, 2 => 6], $result); - } - public static function provideEagerEquivalents(): iterable { $double = static fn ($x) => $x * 2; @@ -88,6 +77,7 @@ class LazyTest extends \PHPUnit\Framework\TestCase yield 'reject' => [fn () => lazy\reject($isTwo), fn () => c\reject($isTwo)]; yield 'flatMap' => [fn () => lazy\flatMap($inner), fn () => c\flatMap($inner)]; yield 'values' => [fn () => lazy\values(), fn () => c\values()]; + yield 'keys' => [fn () => lazy\keys(), fn () => c\keys()]; yield 'unique' => [fn () => lazy\unique(), fn () => c\unique()]; yield 'uniqueBy' => [fn () => lazy\uniqueBy($double), fn () => c\uniqueBy($double)]; yield 'slice' => [fn () => lazy\slice(1, 1), fn () => c\slice(1, 1)]; @@ -111,14 +101,6 @@ class LazyTest extends \PHPUnit\Framework\TestCase $this->assertSame($eager()($fixture), iterator_to_array($lazy()($fixture))); } - public function testKeysMatchesEager() - { - $fixture = ['a' => 1, 'b' => 2]; - - $this->assertSame(['a', 'b'], iterator_to_array(lazy\keys()($fixture))); - $this->assertSame([0, 1], array_keys(iterator_to_array(lazy\keys()($fixture)))); - } - public function testLazyUniqueStreams() { $walked = 0; @@ -169,11 +151,6 @@ class LazyTest extends \PHPUnit\Framework\TestCase lazy\skip(-1); } - public function testTakeStopsPullingTheSource() - { - $this->assertSame([1, 2], array_values(iterator_to_array(lazy\take(2)(self::naturals())))); - } - public function testEachYieldsEverythingThroughWithKeys() { $seen = []; @@ -183,7 +160,7 @@ class LazyTest extends \PHPUnit\Framework\TestCase $this->assertSame([['a', 1], ['b', 2]], $seen); } - public function testCallbackIsResolvedOncePerStep() + public function testStepCanBeReusedAcrossInputs() { $step = lazy\map(static fn ($x) => $x + 1);