1--TEST--
2Random: Randomizer: Native engines can be wrapped without changing their sequence
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Engine\Mt19937;
8use Random\Engine\PcgOneseq128XslRr64;
9use Random\Engine\Test\TestWrapperEngine;
10use Random\Engine\Xoshiro256StarStar;
11use Random\Randomizer;
12
13require __DIR__ . "/../engines.inc";
14
15$engines = [];
16$engines[] = new Mt19937(1234);
17$engines[] = new PcgOneseq128XslRr64(1234);
18$engines[] = new Xoshiro256StarStar(1234);
19
20foreach ($engines as $engine) {
21    echo $engine::class, PHP_EOL;
22
23    $native_randomizer = new Randomizer(clone $engine);
24    $user_randomizer = new Randomizer(new TestWrapperEngine(clone $engine));
25
26    for ($i = 0; $i < 10_000; $i++) {
27        $native = $native_randomizer->getInt(0, $i);
28        $user = $user_randomizer->getInt(0, $i);
29
30        if ($native !== $user) {
31            die("failure: state differs at {$i}");
32        }
33    }
34}
35
36die('success');
37
38?>
39--EXPECT--
40Random\Engine\Mt19937
41Random\Engine\PcgOneseq128XslRr64
42Random\Engine\Xoshiro256StarStar
43success
44