1--TEST--
2Random: Randomizer: The engine property must be readonly
3--FILE--
4<?php
5
6use Random\Engine\PcgOneseq128XslRr64;
7use Random\Engine\Xoshiro256StarStar;
8use Random\Randomizer;
9
10$randomizer = new Randomizer(new PcgOneseq128XslRr64(1234));
11$referenceRandomizer = new Randomizer(new PcgOneseq128XslRr64(1234));
12
13try {
14    $randomizer->engine = new Xoshiro256StarStar(1234);
15} catch (Throwable $e) {
16    echo $e->getMessage(), PHP_EOL;
17}
18
19for ($i = 0; $i < 10_000; $i++) {
20    if ($randomizer->getInt(0, $i) !== $referenceRandomizer->getInt(0, $i)) {
21        die("failure: state differs at {$i}");
22    }
23}
24
25die('success');
26
27?>
28--EXPECT--
29Cannot modify readonly property Random\Randomizer::$engine
30success
31