1--TEST-- 2Random: Engine: Serialization of native engines must preserve the sequence 3--FILE-- 4<?php 5 6use Random\Engine\Mt19937; 7use Random\Engine\PcgOneseq128XslRr64; 8use Random\Engine\Xoshiro256StarStar; 9 10$engines = []; 11$engines[] = new Mt19937(1234); 12$engines[] = new PcgOneseq128XslRr64(1234); 13$engines[] = new Xoshiro256StarStar(1234); 14 15foreach ($engines as $engine) { 16 echo $engine::class, PHP_EOL; 17 18 for ($i = 0; $i < 10_000; $i++) { 19 $engine->generate(); 20 } 21 22 $engine2 = unserialize(serialize($engine)); 23 24 for ($i = 0; $i < 10_000; $i++) { 25 if ($engine->generate() !== $engine2->generate()) { 26 die("failure: state differs at {$i}"); 27 } 28 } 29} 30 31die('success'); 32 33?> 34--EXPECT-- 35Random\Engine\Mt19937 36Random\Engine\PcgOneseq128XslRr64 37Random\Engine\Xoshiro256StarStar 38success 39