mt_rand_variation1.phpt [plain text]
--TEST--
Test rand() function : usage variations - different data types as $min argument
--FILE--
<?php
echo "*** Testing mt_rand() : usage variations ***\n";
$unset_var = 10;
unset ($unset_var);
$heredoc = <<<EOT
abc
xyz
EOT;
class classA
{
}
$fp = fopen(__FILE__, "r");
$inputs = array(
0,
1,
12345,
-2345,
2147483647,
10.5,
-10.5,
12.3456789000E8,
12.3456789000E-10,
.5,
NULL,
null,
true,
false,
TRUE,
FALSE,
"",
'',
array(),
"abcxyz",
'abcxyz',
$heredoc,
new classA(),
@$undefined_var,
@$unset_var,
$fp
);
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump(mt_rand($input, mt_getrandmax()));
$iterator++;
};
fclose($fp);
?>
===Done===
--EXPECTF--
*** Testing mt_rand() : usage variations ***
-- Iteration 1 --
int(%i)
-- Iteration 2 --
int(%i)
-- Iteration 3 --
int(%i)
-- Iteration 4 --
int(%i)
-- Iteration 5 --
int(%i)
-- Iteration 6 --
int(%i)
-- Iteration 7 --
int(%i)
-- Iteration 8 --
int(%i)
-- Iteration 9 --
int(%i)
-- Iteration 10 --
int(%i)
-- Iteration 11 --
int(%i)
-- Iteration 12 --
int(%i)
-- Iteration 13 --
int(%i)
-- Iteration 14 --
int(%i)
-- Iteration 15 --
int(%i)
-- Iteration 16 --
int(%i)
-- Iteration 17 --
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line %d
NULL
-- Iteration 18 --
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line %d
NULL
-- Iteration 19 --
Warning: mt_rand() expects parameter 1 to be long, array given in %s on line %d
NULL
-- Iteration 20 --
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line %d
NULL
-- Iteration 21 --
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line %d
NULL
-- Iteration 22 --
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line %d
NULL
-- Iteration 23 --
Warning: mt_rand() expects parameter 1 to be long, object given in %s on line %d
NULL
-- Iteration 24 --
int(%i)
-- Iteration 25 --
int(%i)
-- Iteration 26 --
Warning: mt_rand() expects parameter 1 to be long, resource given in %s on line %d
NULL
===Done===