Skip to content

Commit 27f5e65

Browse files
committed
Configurable max digits in random-tests.php
1 parent d82cfbb commit 27f5e65

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

random-tests.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@
1313

1414
use const PHP_EOL;
1515

16-
(new class(30) { // max digits
16+
if ($argc !== 2) {
17+
echo 'Usage: php random-tests.php <max number of digits>', PHP_EOL;
18+
exit(1);
19+
}
20+
21+
$maxDigits = (int) $argv[1];
22+
23+
if ($maxDigits < 1) {
24+
echo 'Max digits must be > 1', PHP_EOL;
25+
exit(1);
26+
}
27+
28+
(new class($maxDigits) {
1729
private readonly Calculator\GmpCalculator $gmp;
1830

1931
private readonly Calculator\BcMathCalculator $bcmath;
@@ -146,7 +158,7 @@ private function failure(string $c1, string $c2, string $test): never
146158
echo 'FAILURE!', PHP_EOL;
147159
echo $c1, ' vs ', $c2, PHP_EOL;
148160
echo $test, PHP_EOL;
149-
die;
161+
exit(1);
150162
}
151163

152164
private function generateRandomNumber(): string

0 commit comments

Comments
 (0)