diff --git a/tests/Set/CharsTest.php b/tests/Set/CharsTest.php index affd000..93f1075 100644 --- a/tests/Set/CharsTest.php +++ b/tests/Set/CharsTest.php @@ -21,7 +21,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $even); $this->assertNotSame($values, $even); $hasOddChar = \array_reduce( - $this->unwrap($values->take(100)->values(Random::mersenneTwister)), + $this->unwrap($values->take(100)), static function(bool $hasOddChar, string $value): bool { return $hasOddChar || \ord($value) % 2 === 1; }, @@ -30,7 +30,7 @@ static function(bool $hasOddChar, string $value): bool { $this->assertTrue($hasOddChar); $hasOddChar = \array_reduce( - $this->unwrap($even->take(100)->values(Random::mersenneTwister)), + $this->unwrap($even->take(100)), static function(bool $hasOddChar, string $value): bool { return $hasOddChar || \ord($value) % 2 === 1; }, @@ -46,8 +46,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -55,7 +55,7 @@ public function testValues() $a = Set::strings()->chars()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/CompositeTest.php b/tests/Set/CompositeTest.php index fa9b78e..7250f9c 100644 --- a/tests/Set/CompositeTest.php +++ b/tests/Set/CompositeTest.php @@ -30,7 +30,7 @@ static function(string ...$args) { public function testTake() { - $values = $this->unwrap($this->set->take(500)->values(Random::mersenneTwister)); + $values = $this->unwrap($this->set->take(500)); $this ->assert() @@ -53,7 +53,7 @@ public function testFilter() $this ->assert() - ->array($this->unwrap($values->values(Random::mersenneTwister))) + ->array($this->unwrap($values)) ->contains('eac') ->contains('ead') ->contains('ebc') @@ -67,7 +67,7 @@ public function testFilter() public function testReduce() { - $values = $this->unwrap($this->set->take(100)->values(Random::mersenneTwister)); + $values = $this->unwrap($this->set->take(100)); $this ->assert() @@ -85,7 +85,7 @@ public function testReduce() public function testValues() { $this->assertInstanceOf(\Generator::class, $this->set->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($this->set->take(100)->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($this->set->take(100))); foreach ($this->set->take(100)->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/DecorateTest.php b/tests/Set/DecorateTest.php index d1bd640..94de687 100644 --- a/tests/Set/DecorateTest.php +++ b/tests/Set/DecorateTest.php @@ -52,7 +52,7 @@ public function testFilteringDecoratedDecoratorIsAppliedCorrectly() ->set ->map(static fn($value) => [$value]) ->filter(static fn($value) => $value[0][0][0] === 'e'); - $values = $this->unwrap($values->values(Random::mersenneTwister)); + $values = $this->unwrap($values); $this ->assert() @@ -63,7 +63,7 @@ public function testFilteringDecoratedDecoratorIsAppliedCorrectly() public function testReduce() { - $values = $this->unwrap($this->set->values(Random::mersenneTwister)); + $values = $this->unwrap($this->set); $this ->assert() @@ -77,7 +77,7 @@ public function testReduce() public function testValues() { $this->assertInstanceOf(\Generator::class, $this->set->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($this->set->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($this->set)); foreach ($this->set->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/EitherTest.php b/tests/Set/EitherTest.php index c8dc43d..53427a6 100644 --- a/tests/Set/EitherTest.php +++ b/tests/Set/EitherTest.php @@ -33,8 +33,8 @@ public function testTake() $this->assertNotSame($either1, $either2); $this->assertInstanceOf(Set::class, $either2); - $this->assertCount(100, $this->unwrap($either1->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($either2->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($either1)); + $this->assertCount(50, $this->unwrap($either2)); } public function testFilter() @@ -52,8 +52,8 @@ public function testFilter() $this->assertNotSame($either, $either2); $this->assertInstanceOf(Set::class, $either2); - $this->assertSame([1], \array_unique($this->unwrap($either2->values(Random::mersenneTwister)))); - $unique = \array_unique($this->unwrap($either->values(Random::mersenneTwister))); + $this->assertSame([1], \array_unique($this->unwrap($either2))); + $unique = \array_unique($this->unwrap($either)); \sort($unique); $this->assertSame([null, 1, 2], $unique); } diff --git a/tests/Set/ElementsTest.php b/tests/Set/ElementsTest.php index 6b7cd67..26b0640 100644 --- a/tests/Set/ElementsTest.php +++ b/tests/Set/ElementsTest.php @@ -20,7 +20,7 @@ public function testInterface() public function testTake100ValuesByDefault() { $elements = Set::of(...\range(0, 1000)); - $values = $this->unwrap($elements->take(100)->values(Random::mersenneTwister)); + $values = $this->unwrap($elements->take(100)); $this->assertCount(100, $values); } @@ -29,8 +29,8 @@ public function testTake() { $elements = Set::of(...\range(0, 1000)); $elements2 = $elements->take(10); - $aValues = $this->unwrap($elements->take(100)->values(Random::mersenneTwister)); - $bValues = $this->unwrap($elements2->values(Random::mersenneTwister)); + $aValues = $this->unwrap($elements->take(100)); + $bValues = $this->unwrap($elements2); $this->assertInstanceOf(Set::class, $elements2); $this->assertNotSame($elements, $elements2); @@ -52,14 +52,14 @@ public function testFilter() $this->assertNotSame($elements, $elements2); $this->assertFalse( \array_reduce( - $this->unwrap($elements2->values(Random::mersenneTwister)), + $this->unwrap($elements2), $containsEvenInt, false, ), ); $this->assertTrue( \array_reduce( - $this->unwrap($elements->values(Random::mersenneTwister)), + $this->unwrap($elements), $containsEvenInt, false, ), @@ -71,7 +71,7 @@ public function testValues() $elements = Set::of(...\range(0, 1000))->take(100); $this->assertInstanceOf(\Generator::class, $elements->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($elements->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($elements)); foreach ($elements->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/IntegersExceptZeroTest.php b/tests/Set/IntegersExceptZeroTest.php index cfd7b0f..59619b0 100644 --- a/tests/Set/IntegersExceptZeroTest.php +++ b/tests/Set/IntegersExceptZeroTest.php @@ -26,7 +26,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $even); $this->assertNotSame($integers, $even); $hasOddInteger = \array_reduce( - $this->unwrap($integers->values(Random::mersenneTwister)), + $this->unwrap($integers), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -35,7 +35,7 @@ static function(bool $hasOddInteger, int $value): bool { $this->assertTrue($hasOddInteger); $hasOddInteger = \array_reduce( - $this->unwrap($even->values(Random::mersenneTwister)), + $this->unwrap($even), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -51,8 +51,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -60,7 +60,7 @@ public function testValues() $a = Set::integers()->exceptZero()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/IntegersTest.php b/tests/Set/IntegersTest.php index 1ca8ce6..e2341f6 100644 --- a/tests/Set/IntegersTest.php +++ b/tests/Set/IntegersTest.php @@ -22,7 +22,7 @@ public function testBoundsAreApplied() $values = Set::integers()->between(-10, 10)->take(100); $hasOutsideBounds = \array_reduce( - $this->unwrap($values->values(Random::mersenneTwister)), + $this->unwrap($values), static function(bool $hasOutsideBounds, int $value): bool { return $hasOutsideBounds || $value > 10 || $value < -10; }, @@ -37,10 +37,10 @@ public function testAbove() $values = Set::integers()->above(10)->take(100); $this->assertInstanceOf(Set::class, $values); - $this->assertCount(100, $this->unwrap($values->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($values)); $this->assertGreaterThanOrEqual( 10, - \min($this->unwrap($values->values(Random::mersenneTwister))), + \min($this->unwrap($values)), ); } @@ -49,10 +49,10 @@ public function testBelow() $values = Set::integers()->below(10)->take(100); $this->assertInstanceOf(Set::class, $values); - $this->assertCount(100, $this->unwrap($values->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($values)); $this->assertLessThanOrEqual( 10, - \max($this->unwrap($values->values(Random::mersenneTwister))), + \max($this->unwrap($values)), ); } @@ -66,7 +66,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $even); $this->assertNotSame($integers, $even); $hasOddInteger = \array_reduce( - $this->unwrap($integers->values(Random::mersenneTwister)), + $this->unwrap($integers), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -75,7 +75,7 @@ static function(bool $hasOddInteger, int $value): bool { $this->assertTrue($hasOddInteger); $hasOddInteger = \array_reduce( - $this->unwrap($even->values(Random::mersenneTwister)), + $this->unwrap($even), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -91,8 +91,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -100,7 +100,7 @@ public function testValues() $a = Set::integers()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/NaturalNumbersExceptZeroTest.php b/tests/Set/NaturalNumbersExceptZeroTest.php index 65b9d61..5321464 100644 --- a/tests/Set/NaturalNumbersExceptZeroTest.php +++ b/tests/Set/NaturalNumbersExceptZeroTest.php @@ -21,8 +21,7 @@ public function testByDefault100IntegersAreGenerated() $values = $this->unwrap( Set::integers() ->naturalNumbersExceptZero() - ->take(100) - ->values(Random::mersenneTwister), + ->take(100), ); $this->assertCount(100, $values); @@ -42,7 +41,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $even); $this->assertNotSame($integers, $even); $hasOddInteger = \array_reduce( - $this->unwrap($integers->values(Random::mersenneTwister)), + $this->unwrap($integers), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -51,7 +50,7 @@ static function(bool $hasOddInteger, int $value): bool { $this->assertTrue($hasOddInteger); $hasOddInteger = \array_reduce( - $this->unwrap($even->values(Random::mersenneTwister)), + $this->unwrap($even), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -67,8 +66,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -76,7 +75,7 @@ public function testValues() $a = Set::integers()->naturalNumbersExceptZero()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/NaturalNumbersTest.php b/tests/Set/NaturalNumbersTest.php index 2daaa3d..1455396 100644 --- a/tests/Set/NaturalNumbersTest.php +++ b/tests/Set/NaturalNumbersTest.php @@ -21,8 +21,7 @@ public function testByDefault100IntegersAreGenerated() $values = $this->unwrap( Set::integers() ->naturalNumbers() - ->take(100) - ->values(Random::mersenneTwister), + ->take(100), ); $this->assertCount(100, $values); @@ -42,7 +41,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $even); $this->assertNotSame($integers, $even); $hasOddInteger = \array_reduce( - $this->unwrap($integers->values(Random::mersenneTwister)), + $this->unwrap($integers), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -51,7 +50,7 @@ static function(bool $hasOddInteger, int $value): bool { $this->assertTrue($hasOddInteger); $hasOddInteger = \array_reduce( - $this->unwrap($even->values(Random::mersenneTwister)), + $this->unwrap($even), static function(bool $hasOddInteger, int $value): bool { return $hasOddInteger || $value % 2 === 1; }, @@ -67,8 +66,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -76,7 +75,7 @@ public function testValues() $a = Set::integers()->naturalNumbers()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/NullableTest.php b/tests/Set/NullableTest.php index 30a2fd8..e83999f 100644 --- a/tests/Set/NullableTest.php +++ b/tests/Set/NullableTest.php @@ -3,16 +3,13 @@ namespace Tests\Innmind\BlackBox\Set; -use Innmind\BlackBox\{ - Set, - Random, -}; +use Innmind\BlackBox\Set; class NullableTest extends TestCase { public function testByDefault100ValuesAreGenerated() { - $values = $this->unwrap(Set::integers()->nullable()->take(100)->values(Random::mersenneTwister)); + $values = $this->unwrap(Set::integers()->nullable()->take(100)); $this->assertContains(null, $values); } diff --git a/tests/Set/PropertiesTest.php b/tests/Set/PropertiesTest.php index bae65d4..1082226 100644 --- a/tests/Set/PropertiesTest.php +++ b/tests/Set/PropertiesTest.php @@ -95,14 +95,14 @@ public function testFilter() $this->assertTrue( \array_reduce( - $this->unwrap($properties->toSet()->take(100)->values(Random::mersenneTwister)), + $this->unwrap($properties->toSet()->take(100)), $hasUnder50Properties, false, ), ); $this->assertFalse( \array_reduce( - $this->unwrap($properties2->toSet()->take(100)->values(Random::mersenneTwister)), + $this->unwrap($properties2->toSet()->take(100)), $hasUnder50Properties, false, ), diff --git a/tests/Set/RandomizeTest.php b/tests/Set/RandomizeTest.php index 4213e2b..dbeeefa 100644 --- a/tests/Set/RandomizeTest.php +++ b/tests/Set/RandomizeTest.php @@ -25,7 +25,7 @@ public function testGenerate100ValuesByDefault() ->randomize() ->take(100); - $this->assertCount(100, $this->unwrap($set->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($set)); } public function testTake() @@ -37,8 +37,8 @@ public function testTake() $this->assertInstanceOf(Set::class, $set2); $this->assertNotSame($set2, $set1); - $this->assertCount(100, $this->unwrap($set1->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($set2->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($set1)); + $this->assertCount(50, $this->unwrap($set2)); } public function testFilter() @@ -50,15 +50,15 @@ public function testFilter() $this->assertInstanceOf(Set::class, $set2); $this->assertNotSame($set2, $set1); - $this->assertCount(100, $this->unwrap($set1->values(Random::mersenneTwister))); - $this->assertCount(100, $this->unwrap($set2->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($set1)); + $this->assertCount(100, $this->unwrap($set2)); $this->assertCount( 2, - \array_unique($this->unwrap($set1->values(Random::mersenneTwister))), + \array_unique($this->unwrap($set1)), ); $this->assertCount( 1, - \array_unique($this->unwrap($set2->values(Random::mersenneTwister))), + \array_unique($this->unwrap($set2)), ); } diff --git a/tests/Set/RealNumbersTest.php b/tests/Set/RealNumbersTest.php index 9c174f2..b9a54b0 100644 --- a/tests/Set/RealNumbersTest.php +++ b/tests/Set/RealNumbersTest.php @@ -55,7 +55,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $positive); $this->assertNotSame($values, $positive); $hasNegative = \array_reduce( - $this->unwrap($values->values(Random::mersenneTwister)), + $this->unwrap($values), static function(bool $hasNegative, float $value): bool { return $hasNegative || $value <=0; }, @@ -64,7 +64,7 @@ static function(bool $hasNegative, float $value): bool { $this->assertTrue($hasNegative); $hasNegative = \array_reduce( - $this->unwrap($positive->values(Random::mersenneTwister)), + $this->unwrap($positive), static function(bool $hasNegative, float $value): bool { return $hasNegative || $value <= 0; }, @@ -80,8 +80,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -89,7 +89,7 @@ public function testValues() $a = Set::realNumbers()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/StringsTest.php b/tests/Set/StringsTest.php index 44f725d..a5a5580 100644 --- a/tests/Set/StringsTest.php +++ b/tests/Set/StringsTest.php @@ -17,11 +17,7 @@ public function testByDefaultMaxLengthIs128() static function(string $value): int { return \strlen($value); }, - $this->unwrap( - Set::strings() - ->take(100) - ->values(Random::mersenneTwister), - ), + $this->unwrap(Set::strings()->take(100)), ); $this->assertLessThanOrEqual(128, \max($values)); @@ -36,8 +32,7 @@ static function(string $value): int { $this->unwrap( Set::strings() ->atMost(256) - ->take(100) - ->values(Random::mersenneTwister), + ->take(100), ), ); @@ -53,7 +48,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertNotSame($values, $others); $hasLengthAbove10 = \array_reduce( - $this->unwrap($values->values(Random::mersenneTwister)), + $this->unwrap($values), static function(bool $hasLengthAbove10, string $value): bool { return $hasLengthAbove10 || \strlen($value) > 10; }, @@ -62,7 +57,7 @@ static function(bool $hasLengthAbove10, string $value): bool { $this->assertTrue($hasLengthAbove10); $hasLengthAbove10 = \array_reduce( - $this->unwrap($others->values(Random::mersenneTwister)), + $this->unwrap($others), static function(bool $hasLengthAbove10, string $value): bool { return $hasLengthAbove10 || \strlen($value) > 10; }, @@ -77,8 +72,8 @@ public function testSizeAppliedOnReturnedSetOnly() $b = $a->take(50); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -86,7 +81,7 @@ public function testValues() $a = Set::strings()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value); diff --git a/tests/Set/TestCase.php b/tests/Set/TestCase.php index 56c188d..340b5e7 100644 --- a/tests/Set/TestCase.php +++ b/tests/Set/TestCase.php @@ -3,15 +3,13 @@ namespace Tests\Innmind\BlackBox\Set; -use Innmind\BlackBox\Set\Value; +use Innmind\BlackBox\Set; use Innmind\BlackBox\PHPUnit\Framework\TestCase as BaseTestCase; class TestCase extends BaseTestCase { - public function unwrap(\Generator $values): array + public function unwrap(Set $values): array { - $values = \iterator_to_array($values); - - return \array_map(static fn(Value $value) => $value->unwrap(), $values); + return \iterator_to_array($values->enumerate()); } } diff --git a/tests/Set/UnsafeStringsTest.php b/tests/Set/UnsafeStringsTest.php index bc2ed08..6dcbba2 100644 --- a/tests/Set/UnsafeStringsTest.php +++ b/tests/Set/UnsafeStringsTest.php @@ -22,7 +22,7 @@ public function testPredicateIsAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $others); $this->assertNotSame($values, $others); $hasLengthAbove10 = \array_reduce( - $this->unwrap($values->values(Random::mersenneTwister)), + $this->unwrap($values), static function(bool $hasLengthAbove10, string $value): bool { return $hasLengthAbove10 || \strlen($value) > 10; }, @@ -31,7 +31,7 @@ static function(bool $hasLengthAbove10, string $value): bool { $this->assertTrue($hasLengthAbove10); $hasLengthAbove10 = \array_reduce( - $this->unwrap($others->values(Random::mersenneTwister)), + $this->unwrap($others), static function(bool $hasLengthAbove10, string $value): bool { return $hasLengthAbove10 || \strlen($value) > 10; }, @@ -47,8 +47,8 @@ public function testSizeAppliedOnReturnedSetOnly() $this->assertInstanceOf(Set::class, $b); $this->assertNotSame($a, $b); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); - $this->assertCount(50, $this->unwrap($b->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); + $this->assertCount(50, $this->unwrap($b)); } public function testValues() @@ -56,7 +56,7 @@ public function testValues() $a = Set::strings()->unsafe()->take(100); $this->assertInstanceOf(\Generator::class, $a->values(Random::mersenneTwister)); - $this->assertCount(100, $this->unwrap($a->values(Random::mersenneTwister))); + $this->assertCount(100, $this->unwrap($a)); foreach ($a->values(Random::mersenneTwister) as $value) { $this->assertInstanceOf(Value::class, $value);