1--TEST--
2Random: Engine: 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;
11
12require __DIR__ . "/../engines.inc";
13
14$engines = [];
15$engines[] = new Mt19937(1234);
16$engines[] = new PcgOneseq128XslRr64(1234);
17$engines[] = new Xoshiro256StarStar(1234);
18
19foreach ($engines as $engine) {
20    echo $engine::class, PHP_EOL;
21
22    $native_engine = clone $engine;
23    $user_engine = new TestWrapperEngine(clone $engine);
24
25    for ($i = 0; $i < 10_000; $i++) {
26        if ($native_engine->generate() !== $user_engine->generate()) {
27            die("failure: state differs at {$i}");
28        }
29    }
30}
31
32die('success');
33
34?>
35--EXPECT--
36Random\Engine\Mt19937
37Random\Engine\PcgOneseq128XslRr64
38Random\Engine\Xoshiro256StarStar
39success
40