Skip to content

Commit

Permalink
Use constants instead of hardcoded values for PHP_INT_(MAX|MIN) to ru…
Browse files Browse the repository at this point in the history
…n tests successfully on 32/64-bit systems (#1490)
  • Loading branch information
maks-rafalko committed Feb 23, 2021
1 parent c52cdc8 commit d7dcd4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions tests/phpunit/Mutator/Number/DecrementIntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
namespace Infection\Tests\Mutator\Number;

use Infection\Tests\Mutator\BaseMutatorTestCase;
use const PHP_INT_MIN;

final class DecrementIntegerTest extends BaseMutatorTestCase
{
Expand Down Expand Up @@ -507,11 +508,13 @@ public function mutationsProvider(): iterable
PHP
];

$minInt = PHP_INT_MIN;

yield 'It does not decrement min int' => [
<<<'PHP'
<<<"PHP"
<?php

if ($a === -9223372036854775808) {
if (1 === {$minInt}) {
echo 'bar';
}
PHP
Expand Down
11 changes: 7 additions & 4 deletions tests/phpunit/Mutator/Number/IncrementIntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
namespace Infection\Tests\Mutator\Number;

use Infection\Tests\Mutator\BaseMutatorTestCase;
use const PHP_INT_MAX;

final class IncrementIntegerTest extends BaseMutatorTestCase
{
Expand Down Expand Up @@ -242,17 +243,19 @@ public function mutationsProvider(): iterable
PHP
];

$maxInt = PHP_INT_MAX;

yield 'It does not increment max int' => [
<<<'PHP'
<<<"PHP"
<?php

random_int(10000000, 9223372036854775807);
random_int(10000000, {$maxInt});
PHP
,
<<<'PHP'
<<<"PHP"
<?php

random_int(10000001, 9223372036854775807);
random_int(10000001, {$maxInt});
PHP
];
}
Expand Down

0 comments on commit d7dcd4f

Please sign in to comment.