1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 14:31:06 +02:00
Files
archived-php-src/ext/random/tests/03_randomizer/readonly.phpt
Tim Düsterhus f7d426cca6 Unify structure for ext/random's randomizer tests (#9410)
* Unify structure for ext/random's engine tests (2)

This makes adjustments that were missed in
2d6a883b3a.

* Add `engines.inc` for ext/random tests

* Unify structure for ext/random's randomizer tests
2022-08-31 19:22:39 +02:00

31 lines
707 B
PHP

--TEST--
Random: Randomizer: The engine property must be readonly
--FILE--
<?php
use Random\Engine\PcgOneseq128XslRr64;
use Random\Engine\Xoshiro256StarStar;
use Random\Randomizer;
$randomizer = new Randomizer(new PcgOneseq128XslRr64(1234));
$referenceRandomizer = new Randomizer(new PcgOneseq128XslRr64(1234));
try {
$randomizer->engine = new Xoshiro256StarStar(1234);
} catch (Throwable $e) {
echo $e->getMessage(), PHP_EOL;
}
for ($i = 0; $i < 10_000; $i++) {
if ($randomizer->getInt(0, $i) !== $referenceRandomizer->getInt(0, $i)) {
die("failure: state differs at {$i}");
}
}
die('success');
?>
--EXPECT--
Cannot modify readonly property Random\Randomizer::$engine
success