Skip to content

Commit

Permalink
regenerate the value of Set\Call when shrinking
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Jul 29, 2023
1 parent 4c4c93a commit 3a13c2b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

## 5.1.1 - 2023-07-29

### Changed

- `Innmind\BlackBox\Set\Call` now regenerate the value when shrinking

## 5.1.0 - 2023-07-14

### Added
Expand Down
20 changes: 17 additions & 3 deletions proofs/set/call.php
Expand Up @@ -10,12 +10,26 @@
yield test(
'Set\Call always return a new value',
static function($assert) {
$set = Set\Call::of(static fn() => new \stdClass);
$set = Set\Call::of(static fn() => new \stdClass)->values(Random::default);
$current = $set->current()->unwrap();
$set->next();

$assert
->expected($set->values(Random::default)->current()->unwrap())
->expected($current)
->not()
->same($set->values(Random::default)->current()->unwrap());
->same($set->current()->unwrap());
},
);
yield test(
'Set\Call regenerate the value when shrinking',
static function($assert) {
$set = Set\Call::of(static fn() => new \stdClass)->values(Random::default);
$current = $set->current();

$assert
->expected($current->unwrap())
->not()
->same($current->shrink()->a()->unwrap());
},
);
};
6 changes: 1 addition & 5 deletions src/Set/Call.php
Expand Up @@ -16,10 +16,6 @@ final class Call
*/
public static function of(callable $call): Set
{
return FromGenerator::of(static function() use ($call) {
while (true) {
yield $call();
}
});
return Integers::any()->map(static fn() => $call());
}
}

0 comments on commit 3a13c2b

Please sign in to comment.