Skip to content

Commit

Permalink
Improves once related tests so they never fail (#50053)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Feb 12, 2024
1 parent c33547b commit 1d2247f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/Support/OnceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,18 @@ public function testTemporaryDisable()

public function testMemoizationWithinEvals()
{
$firstResolver = eval('return fn () => once( function () { return random_int(1, 1000); } ) ;');
$firstResolver = eval('return fn () => once( function () { return random_int(1, PHP_INT_MAX); } ) ;');

$firstA = $firstResolver();
$firstB = $firstResolver();

$secondResolver = eval('return fn () => fn () => once( function () { return random_int(1, 1000); } ) ;');
$secondResolver = eval('return fn () => fn () => once( function () { return random_int(1, PHP_INT_MAX); } ) ;');

$secondA = $secondResolver()();
$secondB = $secondResolver()();

$third = eval('return once( function () { return random_int(1, 1000); } ) ;');
$fourth = eval('return once( function () { return random_int(1, 1000); } ) ;');
$third = eval('return once( function () { return random_int(1, PHP_INT_MAX); } ) ;');
$fourth = eval('return once( function () { return random_int(1, PHP_INT_MAX); } ) ;');

$this->assertNotSame($firstA, $firstB);
$this->assertNotSame($secondA, $secondB);
Expand Down

0 comments on commit 1d2247f

Please sign in to comment.