1--TEST--
2Test mt_rand() output
3--FILE--
4<?php
5
6mt_srand(12345678, MT_RAND_PHP);
7
8for ($i=0; $i<16; $i++) {
9    echo mt_rand().PHP_EOL;
10}
11echo PHP_EOL;
12
13$x = 0;
14for ($i=0; $i<1024; $i++) {
15    $x ^= mt_rand();
16}
17echo $x.PHP_EOL;
18echo PHP_EOL;
19
20mt_srand(12345678 /*, MT_RAND_MT19937 */);
21
22for ($i=0; $i<16; $i++) {
23    echo mt_rand().PHP_EOL;
24}
25echo PHP_EOL;
26
27$x = 0;
28for ($i=0; $i<1024; $i++) {
29    $x ^= mt_rand();
30}
31echo $x.PHP_EOL;
32
33/*
34 * Note that the output will be different from the original mt19937ar.c,
35 * because PHP's implementation contains a bug. Thus, this test actually
36 * checks to make sure that PHP's behaviour is wrong, but consistently so.
37 */
38
39?>
40--EXPECTF--
411614640687
421711027313
43857485497
44688176834
451386682158
46412773096
47813703253
48898651287
492087374214
501382556330
511640700129
521863374167
531324097651
541923803667
55676334965
56853386222
57
581571178311
59
60527860569
611711027313
621280820687
63688176834
64770499160
65412773096
66813703253
67898651287
6852508912
69757323740
70511765911
71274407457
72833082629
731923803667
741461450755
751301698200
76
771612214270
78