1--TEST--
2Test mt_srand() function : usage variations - different data types as $seed argument
3--SKIPIF--
4<?php if (PHP_INT_SIZE !== 4) die("skip this test is for 32-bit only");
5--FILE--
6<?php
7/* Prototype  : void mt_srand  ([ int $seed  ] )
8 * Description: Seed the better random number generator.
9 * Source code: ext/standard/rand.c
10 */
11
12echo "*** Testing mt_srand() : usage variations ***\n";
13
14//get an unset variable
15$unset_var = 10;
16unset ($unset_var);
17
18// heredoc string
19$heredoc = <<<EOT
20abc
21xyz
22EOT;
23
24// get a class
25class classA
26{
27}
28
29// get a resource variable
30$fp = fopen(__FILE__, "r");
31
32$inputs = array(
33       // int data
34/*1*/  0,
35       1,
36       12345,
37       -2345,
38       2147483647,
39
40       // float data
41/*6*/  10.5,
42       -10.5,
43       12.3456789000e10,
44       12.3456789000E-10,
45       .5,
46
47       // null data
48/*11*/ NULL,
49       null,
50
51       // boolean data
52/*13*/ true,
53       false,
54       TRUE,
55       FALSE,
56
57       // empty data
58/*17*/ "",
59       '',
60       array(),
61
62       // string data
63/*20*/ "abcxyz",
64       'abcxyz',
65       $heredoc,
66
67       // object data
68/*23*/ new classA(),
69
70       // undefined data
71/*24*/ @$undefined_var,
72
73       // unset data
74/*25*/ @$unset_var,
75
76       // resource variable
77/*26*/ $fp
78);
79
80// loop through each element of $inputs to check the behaviour of mt_srand()
81$iterator = 1;
82foreach($inputs as $input) {
83	echo "\n-- Iteration $iterator --\n";
84	var_dump(mt_srand($input));
85	$iterator++;
86};
87fclose($fp);
88?>
89===Done===
90--EXPECTF--
91*** Testing mt_srand() : usage variations ***
92
93-- Iteration 1 --
94NULL
95
96-- Iteration 2 --
97NULL
98
99-- Iteration 3 --
100NULL
101
102-- Iteration 4 --
103NULL
104
105-- Iteration 5 --
106NULL
107
108-- Iteration 6 --
109NULL
110
111-- Iteration 7 --
112NULL
113
114-- Iteration 8 --
115
116Warning: mt_srand() expects parameter 1 to be integer, float given in %s on line %d
117NULL
118
119-- Iteration 9 --
120NULL
121
122-- Iteration 10 --
123NULL
124
125-- Iteration 11 --
126NULL
127
128-- Iteration 12 --
129NULL
130
131-- Iteration 13 --
132NULL
133
134-- Iteration 14 --
135NULL
136
137-- Iteration 15 --
138NULL
139
140-- Iteration 16 --
141NULL
142
143-- Iteration 17 --
144
145Warning: mt_srand() expects parameter 1 to be integer, string given in %s on line %d
146NULL
147
148-- Iteration 18 --
149
150Warning: mt_srand() expects parameter 1 to be integer, string given in %s on line %d
151NULL
152
153-- Iteration 19 --
154
155Warning: mt_srand() expects parameter 1 to be integer, array given in %s on line %d
156NULL
157
158-- Iteration 20 --
159
160Warning: mt_srand() expects parameter 1 to be integer, string given in %s on line %d
161NULL
162
163-- Iteration 21 --
164
165Warning: mt_srand() expects parameter 1 to be integer, string given in %s on line %d
166NULL
167
168-- Iteration 22 --
169
170Warning: mt_srand() expects parameter 1 to be integer, string given in %s on line %d
171NULL
172
173-- Iteration 23 --
174
175Warning: mt_srand() expects parameter 1 to be integer, object given in %s on line %d
176NULL
177
178-- Iteration 24 --
179NULL
180
181-- Iteration 25 --
182NULL
183
184-- Iteration 26 --
185
186Warning: mt_srand() expects parameter 1 to be integer, resource given in %s on line %d
187NULL
188===Done===
189