48 changed files with 1791 additions and 0 deletions
-
38ext/standard/tests/math/dechex_basic.phpt
-
13ext/standard/tests/math/dechex_error.phpt
-
38ext/standard/tests/math/decoct_basic.phpt
-
13ext/standard/tests/math/decoct_error.phpt
-
67ext/standard/tests/math/deg2rad_basic.phpt
-
31ext/standard/tests/math/deg2rad_error.phpt
-
52ext/standard/tests/math/deg2rad_variation.phpt
-
14ext/standard/tests/math/exp_error.phpt
-
209ext/standard/tests/math/fmod_basic.phpt
-
17ext/standard/tests/math/fmod_error.phpt
-
9ext/standard/tests/math/getrandmax_basic.phpt
-
9ext/standard/tests/math/getrandmax_error.phpt
-
46ext/standard/tests/math/hexdec_basic.phpt
-
12ext/standard/tests/math/hexdec_error.phpt
-
18ext/standard/tests/math/hypot_error.phpt
-
41ext/standard/tests/math/is_finite_basic.phpt
-
13ext/standard/tests/math/is_finite_error.phpt
-
42ext/standard/tests/math/is_infinite_basic.phpt
-
12ext/standard/tests/math/is_infinite_error.phpt
-
45ext/standard/tests/math/is_nan_basic.phpt
-
16ext/standard/tests/math/is_nan_error.phpt
-
56ext/standard/tests/math/lcg_value_basic.phpt
-
55ext/standard/tests/math/log10_basic.phpt
-
31ext/standard/tests/math/log10_error.phpt
-
52ext/standard/tests/math/log10_variation.phpt
-
60ext/standard/tests/math/log_basic.phpt
-
17ext/standard/tests/math/log_error.phpt
-
8ext/standard/tests/math/mt_getrandmax_basic.phpt
-
9ext/standard/tests/math/mt_getrandmax_error.phpt
-
102ext/standard/tests/math/mt_rand_basic.phpt
-
19ext/standard/tests/math/mt_rand_error.phpt
-
24ext/standard/tests/math/mt_srand_basic.phpt
-
20ext/standard/tests/math/mt_srand_error.phpt
-
97ext/standard/tests/math/number_format_basic.phpt
-
45ext/standard/tests/math/octdec_basic.phpt
-
12ext/standard/tests/math/octdec_error.phpt
-
14ext/standard/tests/math/pi_basic.phpt
-
37ext/standard/tests/math/pow_basic.phpt
-
19ext/standard/tests/math/pow_error.phpt
-
65ext/standard/tests/math/rad2deg_basic.phpt
-
31ext/standard/tests/math/rad2deg_error.phpt
-
52ext/standard/tests/math/rad2deg_variation.phpt
-
103ext/standard/tests/math/rand_basic.phpt
-
18ext/standard/tests/math/rand_error.phpt
-
18ext/standard/tests/math/sqrt_basic.phpt
-
31ext/standard/tests/math/sqrt_error.phpt
-
24ext/standard/tests/math/srand_basic.phpt
-
17ext/standard/tests/math/srand_error.phpt
@ -0,0 +1,38 @@ |
|||
--TEST-- |
|||
Test dechex() - basic function dechex() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(10, |
|||
3950.5, |
|||
3.9505e3, |
|||
039, |
|||
0x5F, |
|||
"10", |
|||
"3950.5", |
|||
"3.9505e3", |
|||
"039", |
|||
"0x5F", |
|||
true, |
|||
false, |
|||
null, |
|||
); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = dechex($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
string(1) "a" |
|||
string(3) "f6e" |
|||
string(3) "f6e" |
|||
string(1) "3" |
|||
string(2) "5f" |
|||
string(1) "a" |
|||
string(3) "f6e" |
|||
string(1) "3" |
|||
string(2) "27" |
|||
string(1) "0" |
|||
string(1) "1" |
|||
string(1) "0" |
|||
string(1) "0" |
|||
@ -0,0 +1,13 @@ |
|||
--TEST-- |
|||
Test dechex() - wrong params dechex() |
|||
--FILE-- |
|||
<?php |
|||
dechex(); |
|||
dechex(23,2,true); |
|||
?> |
|||
|
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for dechex() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for dechex() in %s on line 3 |
|||
@ -0,0 +1,38 @@ |
|||
--TEST-- |
|||
Test decoct() - basic function test decoct() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(10, |
|||
3950.5, |
|||
3.9505e3, |
|||
039, |
|||
0x5F, |
|||
"10", |
|||
"3950.5", |
|||
"3.9505e3", |
|||
"039", |
|||
"0x5F", |
|||
true, |
|||
false, |
|||
null, |
|||
); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = decoct($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
string(2) "12" |
|||
string(4) "7556" |
|||
string(4) "7556" |
|||
string(1) "3" |
|||
string(3) "137" |
|||
string(2) "12" |
|||
string(4) "7556" |
|||
string(1) "3" |
|||
string(2) "47" |
|||
string(1) "0" |
|||
string(1) "1" |
|||
string(1) "0" |
|||
string(1) "0" |
|||
@ -0,0 +1,13 @@ |
|||
--TEST-- |
|||
Test decoct() - wrong params decoct() |
|||
--FILE-- |
|||
<?php |
|||
decoct(); |
|||
decoct(23,2,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for decoct() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for decoct() in %s on line 3 |
|||
|
|||
@ -0,0 +1,67 @@ |
|||
--TEST-- |
|||
Test return type and value for expected input deg2rad() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float deg2rad(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$file_path = dirname(__FILE__); |
|||
require($file_path."/allowed_rounding_error.inc"); |
|||
|
|||
$arg_0 = 0.0; |
|||
$arg_1 = 90.0; |
|||
$arg_2 = 180.0; |
|||
$arg_3 = 360.0; |
|||
|
|||
|
|||
echo "deg2rad $arg_0 = "; |
|||
$r0 = deg2rad($arg_0); |
|||
var_dump($r0); |
|||
if (allowed_rounding_error($r0 ,0 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
|
|||
echo "deg2rad $arg_1 = "; |
|||
$r1 = deg2rad($arg_1); |
|||
var_dump($r1); |
|||
if (allowed_rounding_error($r1 ,1.5707963267949 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
echo "deg2rad $arg_2 = "; |
|||
$r2 = deg2rad($arg_2); |
|||
var_dump($r2); |
|||
if (allowed_rounding_error($r2 ,3.1415926535898 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
echo "deg2rad $arg_3 = "; |
|||
$r3 = deg2rad($arg_3); |
|||
var_dump($r3); |
|||
if (allowed_rounding_error($r3 ,6.2831853071796 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
deg2rad 0 = float(%f) |
|||
Pass |
|||
deg2rad 90 = float(%f) |
|||
Pass |
|||
deg2rad 180 = float(%f) |
|||
Pass |
|||
deg2rad 360 = float(%f) |
|||
Pass |
|||
@ -0,0 +1,31 @@ |
|||
--TEST-- |
|||
Test wrong number of arguments for deg2rad() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float deg2rad(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$arg_0 = 1.0; |
|||
$extra_arg = 1; |
|||
|
|||
echo "\nToo many arguments\n"; |
|||
var_dump(deg2rad($arg_0, $extra_arg)); |
|||
|
|||
echo "\nToo few arguments\n"; |
|||
var_dump(deg2rad()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Too many arguments |
|||
|
|||
Warning: Wrong parameter count for deg2rad() in %s on line 11 |
|||
NULL |
|||
|
|||
Too few arguments |
|||
|
|||
Warning: Wrong parameter count for deg2rad() in %s on line 14 |
|||
NULL |
|||
@ -0,0 +1,52 @@ |
|||
--TEST-- |
|||
Test variations in usage of deg2rad() |
|||
--INI-- |
|||
precision = 10 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float deg2rad(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
|
|||
//Test deg2rad with a different input values |
|||
|
|||
$values = array(23, |
|||
-23, |
|||
2.345e1, |
|||
-2.345e1, |
|||
0x17, |
|||
027, |
|||
"23", |
|||
"23.45", |
|||
"2.345e1", |
|||
"nonsense", |
|||
"1000", |
|||
"1000ABC", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = deg2rad($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
float(0.401425728) |
|||
float(-0.401425728) |
|||
float(0.4092797096) |
|||
float(-0.4092797096) |
|||
float(0.401425728) |
|||
float(0.401425728) |
|||
float(0.401425728) |
|||
float(0.4092797096) |
|||
float(0.4092797096) |
|||
float(0) |
|||
float(17.45329252) |
|||
float(17.45329252) |
|||
float(0) |
|||
float(0.01745329252) |
|||
float(0) |
|||
@ -0,0 +1,14 @@ |
|||
--TEST-- |
|||
Test exp() - wrong params for exp() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
exp(); |
|||
exp(23,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for exp() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for exp() in %s on line 3 |
|||
@ -0,0 +1,209 @@ |
|||
--TEST-- |
|||
Test fmod() - basic function test fmod() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
$values1 = array(234, |
|||
-234, |
|||
23.45e1, |
|||
-23.45e1, |
|||
0xEA, |
|||
0352, |
|||
"234", |
|||
"234.5", |
|||
"23.45e1", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
$values2 = array(2, |
|||
-2, |
|||
2.3e1, |
|||
-2.3e1, |
|||
0x2, |
|||
02, |
|||
"2", |
|||
"2.3", |
|||
"2.3e1", |
|||
null, |
|||
true, |
|||
false); |
|||
for ($i = 0; $i < count($values1); $i++) { |
|||
echo "\niteration ", $i, "\n"; |
|||
|
|||
for ($j = 0; $j < count($values2); $j++) { |
|||
$res = fmod($values1[$i], $values2[$j]); |
|||
var_dump($res); |
|||
} |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
iteration 0 |
|||
float(0) |
|||
float(0) |
|||
float(4) |
|||
float(4) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(1.7) |
|||
float(4) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 1 |
|||
float(-0) |
|||
float(-0) |
|||
float(-4) |
|||
float(-4) |
|||
float(-0) |
|||
float(-0) |
|||
float(-0) |
|||
float(-1.7) |
|||
float(-4) |
|||
float(NAN) |
|||
float(-0) |
|||
float(NAN) |
|||
|
|||
iteration 2 |
|||
float(0.5) |
|||
float(0.5) |
|||
float(4.5) |
|||
float(4.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(2.2) |
|||
float(4.5) |
|||
float(NAN) |
|||
float(0.5) |
|||
float(NAN) |
|||
|
|||
iteration 3 |
|||
float(-0.5) |
|||
float(-0.5) |
|||
float(-4.5) |
|||
float(-4.5) |
|||
float(-0.5) |
|||
float(-0.5) |
|||
float(-0.5) |
|||
float(-2.2) |
|||
float(-4.5) |
|||
float(NAN) |
|||
float(-0.5) |
|||
float(NAN) |
|||
|
|||
iteration 4 |
|||
float(0) |
|||
float(0) |
|||
float(4) |
|||
float(4) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(1.7) |
|||
float(4) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 5 |
|||
float(0) |
|||
float(0) |
|||
float(4) |
|||
float(4) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(1.7) |
|||
float(4) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 6 |
|||
float(0) |
|||
float(0) |
|||
float(4) |
|||
float(4) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(1.7) |
|||
float(4) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 7 |
|||
float(0.5) |
|||
float(0.5) |
|||
float(4.5) |
|||
float(4.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(2.2) |
|||
float(4.5) |
|||
float(NAN) |
|||
float(0.5) |
|||
float(NAN) |
|||
|
|||
iteration 8 |
|||
float(0.5) |
|||
float(0.5) |
|||
float(4.5) |
|||
float(4.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(0.5) |
|||
float(2.2) |
|||
float(4.5) |
|||
float(NAN) |
|||
float(0.5) |
|||
float(NAN) |
|||
|
|||
iteration 9 |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 10 |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(1) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
|
|||
iteration 11 |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(0) |
|||
float(NAN) |
|||
float(0) |
|||
float(NAN) |
|||
@ -0,0 +1,17 @@ |
|||
--TEST-- |
|||
Test fmod() - wrong params test fmod() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
fmod(); |
|||
fmod(23); |
|||
fmod(23,2,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: fmod() expects exactly 2 parameters, 0 given in %s on line 2 |
|||
|
|||
Warning: fmod() expects exactly 2 parameters, 1 given in %s on line 3 |
|||
|
|||
Warning: fmod() expects exactly 2 parameters, 3 given in %s on line 4 |
|||
@ -0,0 +1,9 @@ |
|||
--TEST-- |
|||
Test getrandmax() - basic function test getrandmax() |
|||
--FILE-- |
|||
<?php |
|||
$biggest_int = getrandmax(); |
|||
var_dump($biggest_int); |
|||
?> |
|||
--EXPECTF-- |
|||
int(%d) |
|||
@ -0,0 +1,9 @@ |
|||
--TEST-- |
|||
Test getrandmax() - wrong params test getrandmax() |
|||
--FILE-- |
|||
<?php |
|||
var_dump($biggest_int = getrandmax(true)); |
|||
?> |
|||
--EXPECTF-- |
|||
Warning: Wrong parameter count for getrandmax() in %s on line 2 |
|||
NULL |
|||
@ -0,0 +1,46 @@ |
|||
--TEST-- |
|||
Test hexdec() - basic function test hexdec() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(0x123abc, |
|||
0x789DEF, |
|||
0x7FFFFFFF, |
|||
0x80000000, |
|||
'0x123abc', |
|||
'0x789DEF', |
|||
'0x7FFFFFFF', |
|||
'0x80000000', |
|||
'0x123XYZABC', |
|||
311015, |
|||
'311015', |
|||
31101.3, |
|||
31.1013e5, |
|||
011237, |
|||
'011237', |
|||
true, |
|||
false, |
|||
null); |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = hexdec($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
int(18433668) |
|||
int(126895953) |
|||
float(142929835591) |
|||
float(142929835592) |
|||
int(1194684) |
|||
int(7904751) |
|||
int(2147483647) |
|||
float(2147483648) |
|||
int(1194684) |
|||
int(3215381) |
|||
int(3215381) |
|||
int(3215379) |
|||
int(51446064) |
|||
int(18279) |
|||
int(70199) |
|||
int(1) |
|||
int(0) |
|||
int(0) |
|||
@ -0,0 +1,12 @@ |
|||
--TEST-- |
|||
Test hexdec() - wrong params test hexdec() |
|||
--FILE-- |
|||
<?php |
|||
hexdec(); |
|||
hexdec('0x123abc',true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for hexdec() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for hexdec() in %s on line 3 |
|||
@ -0,0 +1,18 @@ |
|||
--TEST-- |
|||
Test hypot() - wrong params test hypot() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
hypot(); |
|||
hypot(36); |
|||
hypot(36,25,0); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
|
|||
Warning: Wrong parameter count for hypot() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for hypot() in %s on line 3 |
|||
|
|||
Warning: Wrong parameter count for hypot() in %s on line 4 |
|||
@ -0,0 +1,41 @@ |
|||
--TEST-- |
|||
Test is_finite() - basic function test is_finite() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(234, |
|||
-234, |
|||
23.45e1, |
|||
-23.45e1, |
|||
0xEA, |
|||
0352, |
|||
"234", |
|||
"234.5", |
|||
"23.45e1", |
|||
null, |
|||
true, |
|||
false, |
|||
pow(0, -2), |
|||
acos(1.01)); |
|||
; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = is_finite($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(true) |
|||
bool(false) |
|||
bool(false) |
|||
|
|||
|
|||
@ -0,0 +1,13 @@ |
|||
--TEST-- |
|||
Test is_finite() - wrong params test is_finite() |
|||
--FILE-- |
|||
<?php |
|||
is_finite(); |
|||
is_finite(23,2,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: is_finite() expects exactly 1 parameter, 0 given in %s on line 2 |
|||
|
|||
Warning: is_finite() expects exactly 1 parameter, 3 given in %s on line 3 |
|||
|
|||
@ -0,0 +1,42 @@ |
|||
--TEST-- |
|||
Test is_infinite() - basic function test is_infinite() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(234, |
|||
-234, |
|||
23.45e1, |
|||
-23.45e1, |
|||
0xEA, |
|||
0352, |
|||
"234", |
|||
"234.5", |
|||
"23.45e1", |
|||
null, |
|||
true, |
|||
false, |
|||
pow(0, -2), |
|||
acos(1.01)); |
|||
; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = is_infinite($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(true) |
|||
bool(false) |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,12 @@ |
|||
--TEST-- |
|||
Test is_infinite() - wrong params test is_infinite() |
|||
--FILE-- |
|||
<?php |
|||
is_infinite(); |
|||
is_infinite(23,2,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: is_infinite() expects exactly 1 parameter, 0 given in %s on line 2 |
|||
|
|||
Warning: is_infinite() expects exactly 1 parameter, 3 given in %s on line 3 |
|||
@ -0,0 +1,45 @@ |
|||
--TEST-- |
|||
Test is_nan() - basic function test is_nan() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(234, |
|||
-234, |
|||
23.45e1, |
|||
-23.45e1, |
|||
0xEA, |
|||
0352, |
|||
"234", |
|||
"234.5", |
|||
"23.45e1", |
|||
null, |
|||
true, |
|||
false, |
|||
pow(0, -2), |
|||
acos(1.01)); |
|||
|
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = is_nan($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
?> |
|||
|
|||
--EXPECTF-- |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(false) |
|||
bool(true) |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,16 @@ |
|||
--TEST-- |
|||
Test is_nan() - wrong params test is_nan() |
|||
--FILE-- |
|||
<?php |
|||
is_nan(); |
|||
is_nan(23,2,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: is_nan() expects exactly 1 parameter, 0 given in %s on line 2 |
|||
|
|||
Warning: is_nan() expects exactly 1 parameter, 3 given in %s on line 3 |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,56 @@ |
|||
--TEST-- |
|||
Maths test for xapic versions of lcg_value() |
|||
--FILE-- |
|||
<?php |
|||
|
|||
echo "MATHS test script started\n"; |
|||
|
|||
|
|||
echo "\n lcg_value tests...\n"; |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = lcg_value(); |
|||
|
|||
if (!is_float($res) || $res < 0 || $res > 1) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i != 100) { |
|||
echo "FAILED\n"; |
|||
} else { |
|||
echo "PASSED\n"; |
|||
} |
|||
|
|||
echo "\n lcg_value error cases..spurious args get ignored\n"; |
|||
$res = lcg_value(23); |
|||
|
|||
if (!is_float($res) || $res < 0 || $res > 1) { |
|||
echo "FAILED\n"; |
|||
} else { |
|||
echo "PASSED\n"; |
|||
} |
|||
|
|||
$res = lcg_value(10,false); |
|||
if (!is_float($res) || $res < 0 || $res > 1) { |
|||
echo "FAILED\n"; |
|||
} else { |
|||
echo "PASSED\n"; |
|||
} |
|||
|
|||
echo "MATHS test script completed\n"; |
|||
|
|||
?> |
|||
|
|||
--EXPECT-- |
|||
MATHS test script started |
|||
|
|||
lcg_value tests... |
|||
PASSED |
|||
|
|||
lcg_value error cases..spurious args get ignored |
|||
PASSED |
|||
PASSED |
|||
MATHS test script completed |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,55 @@ |
|||
--TEST-- |
|||
Test return type and value for expected input log10() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float log10(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$file_path = dirname(__FILE__); |
|||
require($file_path."/allowed_rounding_error.inc"); |
|||
|
|||
$arg_0 = 1.0; |
|||
$arg_1 = 10.0; |
|||
$arg_2 = 100.0; |
|||
|
|||
echo "log10 $arg_0 = "; |
|||
$r0 = log10($arg_0); |
|||
var_dump($r0); |
|||
if (allowed_rounding_error($r0 ,0.0 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
|
|||
echo "log10 $arg_1 = "; |
|||
$r1 = log10($arg_1); |
|||
var_dump($r1); |
|||
if (allowed_rounding_error($r1 ,1.0 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
|
|||
echo "log10 $arg_2 = "; |
|||
$r2 = log10($arg_2); |
|||
var_dump($r2); |
|||
if (allowed_rounding_error($r2 ,2.0 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
log10 1 = float(%f) |
|||
Pass |
|||
log10 10 = float(%f) |
|||
Pass |
|||
log10 100 = float(%f) |
|||
Pass |
|||
@ -0,0 +1,31 @@ |
|||
--TEST-- |
|||
Test wrong number of arguments for log10() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float log10(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$arg_0 = 1.0; |
|||
$extra_arg = 1; |
|||
|
|||
echo "\nToo many arguments\n"; |
|||
var_dump(log10($arg_0, $extra_arg)); |
|||
|
|||
echo "\nToo few arguments\n"; |
|||
var_dump(log10()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Too many arguments |
|||
|
|||
Warning: Wrong parameter count for log10() in %s on line 11 |
|||
NULL |
|||
|
|||
Too few arguments |
|||
|
|||
Warning: Wrong parameter count for log10() in %s on line 14 |
|||
NULL |
|||
@ -0,0 +1,52 @@ |
|||
--TEST-- |
|||
Test variations in usage of log10() |
|||
--INI-- |
|||
precision = 10 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float log10(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
|
|||
//Test log10 with a different input values |
|||
|
|||
$values = array(23, |
|||
-23, |
|||
2.345e1, |
|||
-2.345e1, |
|||
0x17, |
|||
027, |
|||
"23", |
|||
"23.45", |
|||
"2.345e1", |
|||
"nonsense", |
|||
"1000", |
|||
"1000ABC", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = log10($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
float(1.361727836) |
|||
float(NAN) |
|||
float(1.370142847) |
|||
float(NAN) |
|||
float(1.361727836) |
|||
float(1.361727836) |
|||
float(1.361727836) |
|||
float(1.370142847) |
|||
float(1.370142847) |
|||
float(-INF) |
|||
float(3) |
|||
float(3) |
|||
float(-INF) |
|||
float(0) |
|||
float(-INF) |
|||
@ -0,0 +1,60 @@ |
|||
--TEST-- |
|||
Test log() - basic function test log() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
$values = array(23, |
|||
-23, |
|||
2.345e1, |
|||
-2.345e1, |
|||
0x17, |
|||
027, |
|||
"23", |
|||
"23.45", |
|||
"2.345e1", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
echo "\n LOG tests...no base\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = log($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
echo "\n LOG tests...base\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = log($values[$i], 4); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
|
|||
--EXPECTF-- |
|||
LOG tests...no base |
|||
float(3.1354942159291) |
|||
float(NAN) |
|||
float(3.1548704948923) |
|||
float(NAN) |
|||
float(3.1354942159291) |
|||
float(3.1354942159291) |
|||
float(3.1354942159291) |
|||
float(3.1548704948923) |
|||
float(3.1548704948923) |
|||
float(-INF) |
|||
float(0) |
|||
float(-INF) |
|||
|
|||
LOG tests...base |
|||
float(2.2617809780285) |
|||
float(NAN) |
|||
float(2.275758008814) |
|||
float(NAN) |
|||
float(2.2617809780285) |
|||
float(2.2617809780285) |
|||
float(2.2617809780285) |
|||
float(2.275758008814) |
|||
float(2.275758008814) |
|||
float(-INF) |
|||
float(0) |
|||
float(-INF) |
|||
@ -0,0 +1,17 @@ |
|||
--TEST-- |
|||
Test log() - wrong params test log() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
log(); |
|||
log(36,4,true); |
|||
log(36, -4); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for log() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for log() in %s on line 3 |
|||
|
|||
Warning: log(): base must be greater than 0 in %s on line 4 |
|||
@ -0,0 +1,8 @@ |
|||
--TEST-- |
|||
Test mt_getrandmax() - basic function test mt_getrandmax() |
|||
--FILE-- |
|||
<?php |
|||
var_dump(mt_getrandmax()); |
|||
?> |
|||
--EXPECTF-- |
|||
int(%d) |
|||
@ -0,0 +1,9 @@ |
|||
--TEST-- |
|||
Test mt_getrandmax() - wrong paramas mt_getrandmax() |
|||
--FILE-- |
|||
<?php |
|||
var_dump(mt_getrandmax(true)); |
|||
?> |
|||
--EXPECTF-- |
|||
Warning: Wrong parameter count for mt_getrandmax() in %s on line 2 |
|||
NULL |
|||
@ -0,0 +1,102 @@ |
|||
--TEST-- |
|||
Test mt_rand() - basic function test mt_rand() |
|||
--FILE-- |
|||
<?php |
|||
$default_max = mt_getrandmax(); |
|||
|
|||
echo "\nmt_rand() tests with default min and max value (i.e 0 thru ", $default_max, ")\n"; |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = mt_rand(); |
|||
|
|||
// By default RAND_MAX is 32768 although no constant is defined for it for user space apps |
|||
if (!is_int($res) || $res < 0 || $res > $default_max) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i != 100) { |
|||
echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; |
|||
} else { |
|||
echo "PASSED: range min = 0 max = ", $default_max, "\n"; |
|||
} |
|||
|
|||
echo "\nmt_rand() tests with defined min and max value\n"; |
|||
|
|||
$min = array(10, |
|||
100, |
|||
10.5, |
|||
10.5e3, |
|||
0x10, |
|||
0400); |
|||
|
|||
$max = array(100, |
|||
1000, |
|||
19.5, |
|||
10.5e5, |
|||
0x10000, |
|||
0700); |
|||
|
|||
for ($x = 0; $x < count($min); $x++) { |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = mt_rand($min[$x], $max[$x]); |
|||
|
|||
if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { |
|||
echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i == 100) { |
|||
echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
} |
|||
} |
|||
|
|||
echo "\nNon-numeric cases\n"; |
|||
$min = array(true, |
|||
false, |
|||
null, |
|||
"10", |
|||
"0x10", |
|||
"10.5"); |
|||
|
|||
// Eexepcted numerical equivalent of above non-numerics |
|||
$minval = array(1, |
|||
0, |
|||
0, |
|||
10, |
|||
0, |
|||
10); |
|||
for ($x = 0; $x < count($min); $x++) { |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = mt_rand($min[$x], 100); |
|||
|
|||
if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { |
|||
echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i == 100) { |
|||
echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; |
|||
} |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
mt_rand() tests with default min and max value (i.e 0 thru 2147483647) |
|||
PASSED: range min = 0 max = 2147483647 |
|||
|
|||
mt_rand() tests with defined min and max value |
|||
PASSED: range min = 10 max = 100 |
|||
PASSED: range min = 100 max = 1000 |
|||
PASSED: range min = 10 max = 19 |
|||
PASSED: range min = 10500 max = 1050000 |
|||
PASSED: range min = 16 max = 65536 |
|||
PASSED: range min = 256 max = 448 |
|||
|
|||
Non-numeric cases |
|||
PASSED range min = 1 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 10 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 10 max = 100 |
|||
@ -0,0 +1,19 @@ |
|||
--TEST-- |
|||
Test mt_rand() - wrong params test mt_rand() |
|||
--FILE-- |
|||
<?php |
|||
mt_rand(25); |
|||
mt_rand(10,100,false); |
|||
mt_rand("one", 100); |
|||
mt_rand(1, "hundered"); |
|||
?> |
|||
|
|||
--EXPECTF-- |
|||
|
|||
Warning: mt_rand() expects exactly 2 parameters, 1 given in %s on line 2 |
|||
|
|||
Warning: mt_rand() expects exactly 2 parameters, 3 given in %s on line 3 |
|||
|
|||
Warning: mt_rand() expects parameter 1 to be long, string given in %s on line 4 |
|||
|
|||
Warning: mt_rand() expects parameter 2 to be long, string given in %s on line 5 |
|||
@ -0,0 +1,24 @@ |
|||
--TEST-- |
|||
Test mt_srand() - basic function (return values) mt_srand() |
|||
--FILE-- |
|||
<?php |
|||
// Should return NULL if given anything that it can convert to long |
|||
// This doesn't actually test what it does with the input :-\ |
|||
var_dump(mt_srand()); |
|||
var_dump(mt_srand(500)); |
|||
var_dump(mt_srand(500.1)); |
|||
var_dump(mt_srand("500")); |
|||
var_dump(mt_srand("500E3")); |
|||
var_dump(mt_srand(true)); |
|||
var_dump(mt_srand(false)); |
|||
var_dump(mt_srand(NULL)); |
|||
?> |
|||
--EXPECTF-- |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
@ -0,0 +1,20 @@ |
|||
--TEST-- |
|||
Test mt_srand() - wrong params test mt_srand() |
|||
--FILE-- |
|||
<?php |
|||
var_dump(mt_srand(500, true)); |
|||
var_dump(mt_srand("fivehundred")); |
|||
var_dump(mt_srand("500ABC")); |
|||
?> |
|||
--EXPECTF-- |
|||
Warning: mt_srand() expects at most 1 parameter, 2 given in %s on line 2 |
|||
NULL |
|||
|
|||
Warning: mt_srand() expects parameter 1 to be long, string given in %s on line 3 |
|||
NULL |
|||
|
|||
Notice: A non well formed numeric value encountered in %s on line 4 |
|||
NULL |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,97 @@ |
|||
--TEST-- |
|||
Test number_format() - basic function test number_format() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(1234.5678, |
|||
-1234.5678, |
|||
1234.6578e4, |
|||
-1234.56789e4, |
|||
0x1234CDEF, |
|||
02777777777, |
|||
"123456789", |
|||
"123.456789", |
|||
"12.3456789e1", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
echo "\n number_format tests.....default\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = number_format($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
echo "\n number_format tests.....with two dp\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = number_format($values[$i], 2); |
|||
var_dump($res); |
|||
} |
|||
|
|||
echo "\n number_format tests.....English format\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = number_format($values[$i], 2, '.', ' '); |
|||
var_dump($res); |
|||
} |
|||
|
|||
echo "\n number_format tests.....French format\n"; |
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = number_format($values[$i], 2, ',' , ' '); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
number_format tests.....default |
|||
string(5) "1,235" |
|||
string(6) "-1,235" |
|||
string(10) "12,346,578" |
|||
string(11) "-12,345,679" |
|||
string(11) "305,450,479" |
|||
string(11) "402,653,183" |
|||
string(11) "123,456,789" |
|||
string(3) "123" |
|||
string(3) "123" |
|||
string(1) "0" |
|||
string(1) "1" |
|||
string(1) "0" |
|||
|
|||
number_format tests.....with two dp |
|||
string(8) "1,234.57" |
|||
string(9) "-1,234.57" |
|||
string(13) "12,346,578.00" |
|||
string(14) "-12,345,678.90" |
|||
string(14) "305,450,479.00" |
|||
string(14) "402,653,183.00" |
|||
string(14) "123,456,789.00" |
|||
string(6) "123.46" |
|||
string(6) "123.46" |
|||
string(4) "0.00" |
|||
string(4) "1.00" |
|||
string(4) "0.00" |
|||
|
|||
number_format tests.....English format |
|||
string(8) "1 234.57" |
|||
string(9) "-1 234.57" |
|||
string(13) "12 346 578.00" |
|||
string(14) "-12 345 678.90" |
|||
string(14) "305 450 479.00" |
|||
string(14) "402 653 183.00" |
|||
string(14) "123 456 789.00" |
|||
string(6) "123.46" |
|||
string(6) "123.46" |
|||
string(4) "0.00" |
|||
string(4) "1.00" |
|||
string(4) "0.00" |
|||
|
|||
number_format tests.....French format |
|||
string(8) "1 234,57" |
|||
string(9) "-1 234,57" |
|||
string(13) "12 346 578,00" |
|||
string(14) "-12 345 678,90" |
|||
string(14) "305 450 479,00" |
|||
string(14) "402 653 183,00" |
|||
string(14) "123 456 789,00" |
|||
string(6) "123,46" |
|||
string(6) "123,46" |
|||
string(4) "0,00" |
|||
string(4) "1,00" |
|||
string(4) "0,00" |
|||
@ -0,0 +1,45 @@ |
|||
--TEST-- |
|||
Test octdec() - basic function test octdec() |
|||
--FILE-- |
|||
<?php |
|||
$values = array(01234567, |
|||
0567, |
|||
017777777777, |
|||
020000000000, |
|||
0x1234ABC, |
|||
12345, |
|||
'01234567', |
|||
'0567', |
|||
'017777777777', |
|||
'020000000000', |
|||
'0x1234ABC', |
|||
'12345', |
|||
31101.3, |
|||
31.1013e5, |
|||
true, |
|||
false, |
|||
null); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = octdec($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
int(14489) |
|||
int(253) |
|||
int(36947879) |
|||
int(4618484) |
|||
int(4104) |
|||
int(5349) |
|||
int(342391) |
|||
int(375) |
|||
int(2147483647) |
|||
float(2147483648) |
|||
int(668) |
|||
int(5349) |
|||
int(102923) |
|||
int(823384) |
|||
int(1) |
|||
int(0) |
|||
int(0) |
|||
@ -0,0 +1,12 @@ |
|||
--TEST-- |
|||
Test octdec() - wrong params test octdec() |
|||
--FILE-- |
|||
<?php |
|||
octdec(); |
|||
octdec('0123567',true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: Wrong parameter count for octdec() in %s on line 2 |
|||
|
|||
Warning: Wrong parameter count for octdec() in %s on line 3 |
|||
@ -0,0 +1,14 @@ |
|||
--TEST-- |
|||
Test pi() - basic function test pi() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
echo pi(), "\n"; |
|||
echo M_PI, "\n"; |
|||
// N.B pi() ignores all specified arguments no error |
|||
// messages are produced if arguments are spcified. |
|||
?> |
|||
--EXPECTF-- |
|||
3.1415926535898 |
|||
3.1415926535898 |
|||
@ -0,0 +1,37 @@ |
|||
--TEST-- |
|||
Test pow() - basic function test pow() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
$values = array(23, |
|||
-23, |
|||
2.345e1, |
|||
-2.345e1, |
|||
0x17, |
|||
027, |
|||
"23", |
|||
"23.45", |
|||
"2.345e1", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = pow($values[$i], 4); |
|||
var_dump($res); |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
int(279841) |
|||
int(279841) |
|||
float(302392.75950625) |
|||
float(302392.75950625) |
|||
int(279841) |
|||
int(279841) |
|||
int(279841) |
|||
float(302392.75950625) |
|||
float(302392.75950625) |
|||
int(0) |
|||
int(1) |
|||
int(0) |
|||
@ -0,0 +1,19 @@ |
|||
--TEST-- |
|||
Test pow() - wrong params test pow() |
|||
--INI-- |
|||
precision=14 |
|||
--FILE-- |
|||
<?php |
|||
pow(); |
|||
pow(36); |
|||
pow(36,4,true); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: pow() expects exactly 2 parameters, 0 given in %s line 2 |
|||
|
|||
Warning: pow() expects exactly 2 parameters, 1 given in %s line 3 |
|||
|
|||
Warning: pow() expects exactly 2 parameters, 3 given in %s line 4 |
|||
|
|||
|
|||
@ -0,0 +1,65 @@ |
|||
--TEST-- |
|||
Test return type and value for expected input rad2deg() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float rad2deg(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$file_path = dirname(__FILE__); |
|||
require($file_path."/allowed_rounding_error.inc"); |
|||
|
|||
$arg_0 = 0.0; |
|||
$arg_1 = 1.570796327; |
|||
$arg_2 = 3.141592654; |
|||
$arg_3 = 6.283185307; |
|||
|
|||
echo "rad2deg $arg_0= "; |
|||
$r0 = rad2deg($arg_0); |
|||
var_dump($r0); |
|||
if (allowed_rounding_error($r0 ,0 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
echo "rad2deg $arg_1 = "; |
|||
$r1 = rad2deg($arg_1); |
|||
var_dump($r1); |
|||
if (allowed_rounding_error($r1 ,90.000000011752)) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
echo "rad2deg $arg_2 = "; |
|||
$r2 = rad2deg($arg_2); |
|||
var_dump($r2); |
|||
if (allowed_rounding_error($r2 ,180.0000000235 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
echo "rad2deg $arg_3 = "; |
|||
$r3 = rad2deg($arg_3); |
|||
var_dump($r3); |
|||
if (allowed_rounding_error($r3 ,359.99999998971 )) { |
|||
echo "Pass\n"; |
|||
} |
|||
else { |
|||
echo "Fail\n"; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
rad2deg 0= float(%f) |
|||
Pass |
|||
rad2deg 1.570796327 = float(%f) |
|||
Pass |
|||
rad2deg 3.141592654 = float(%f) |
|||
Pass |
|||
rad2deg 6.283185307 = float(%f) |
|||
Pass |
|||
@ -0,0 +1,31 @@ |
|||
--TEST-- |
|||
Test wrong number of arguments for rad2deg() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float rad2deg(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$arg_0 = 1.0; |
|||
$extra_arg = 1; |
|||
|
|||
echo "\nToo many arguments\n"; |
|||
var_dump(rad2deg($arg_0, $extra_arg)); |
|||
|
|||
echo "\nToo few arguments\n"; |
|||
var_dump(rad2deg()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Too many arguments |
|||
|
|||
Warning: Wrong parameter count for rad2deg() in %s on line 11 |
|||
NULL |
|||
|
|||
Too few arguments |
|||
|
|||
Warning: Wrong parameter count for rad2deg() in %s on line 14 |
|||
NULL |
|||
@ -0,0 +1,52 @@ |
|||
--TEST-- |
|||
Test variations in usage of rad2deg() |
|||
--INI-- |
|||
precision = 10 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float rad2deg(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
|
|||
//Test rad2deg with a different input values |
|||
|
|||
$values = array(23, |
|||
-23, |
|||
2.345e1, |
|||
-2.345e1, |
|||
0x17, |
|||
027, |
|||
"23", |
|||
"23.45", |
|||
"2.345e1", |
|||
"nonsense", |
|||
"1000", |
|||
"1000ABC", |
|||
null, |
|||
true, |
|||
false); |
|||
|
|||
for ($i = 0; $i < count($values); $i++) { |
|||
$res = rad2deg($values[$i]); |
|||
var_dump($res); |
|||
} |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
float(1317.802929) |
|||
float(-1317.802929) |
|||
float(1343.58603) |
|||
float(-1343.58603) |
|||
float(1317.802929) |
|||
float(1317.802929) |
|||
float(1317.802929) |
|||
float(1343.58603) |
|||
float(1343.58603) |
|||
float(0) |
|||
float(57295.77951) |
|||
float(57295.77951) |
|||
float(0) |
|||
float(57.29577951) |
|||
float(0) |
|||
@ -0,0 +1,103 @@ |
|||
--TEST-- |
|||
Test rand() - basic function test rand() |
|||
--FILE-- |
|||
<?php |
|||
$default_max = getrandmax(); |
|||
|
|||
echo "\nrand() tests with default min and max value (i.e 0 thru ", $default_max, ")\n"; |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = rand(); |
|||
|
|||
// By default RAND_MAX is 32768 although no constant is defined for it for user space apps |
|||
if (!is_int($res) || $res < 0 || $res > $default_max) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i != 100) { |
|||
echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; |
|||
} else { |
|||
echo "PASSED: range min = 0 max = ", $default_max, "\n"; |
|||
} |
|||
|
|||
echo "\nrand() tests with defined min and max value\n"; |
|||
|
|||
$min = array(10, |
|||
100, |
|||
10.5, |
|||
10.5e3, |
|||
0x10, |
|||
0400); |
|||
|
|||
$max = array(100, |
|||
1000, |
|||
19.5, |
|||
10.5e5, |
|||
0x10000, |
|||
0700); |
|||
|
|||
for ($x = 0; $x < count($min); $x++) { |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = rand($min[$x], $max[$x]); |
|||
|
|||
if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { |
|||
echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i == 100) { |
|||
echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
} |
|||
} |
|||
|
|||
echo "\nNon-numeric cases\n"; |
|||
$min = array(true, |
|||
false, |
|||
null, |
|||
"10", |
|||
"0x10", |
|||
"10.5"); |
|||
|
|||
// Eexepcted numerical equivalent of above non-numerics |
|||
$minval = array(1, |
|||
0, |
|||
0, |
|||
10, |
|||
0, |
|||
10); |
|||
for ($x = 0; $x < count($min); $x++) { |
|||
for ($i = 0; $i < 100; $i++) { |
|||
$res = rand($min[$x], 100); |
|||
|
|||
if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { |
|||
echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ($i == 100) { |
|||
echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; |
|||
} |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
rand() tests with default min and max value (i.e 0 thru %i) |
|||
PASSED: range min = 0 max = %i |
|||
|
|||
rand() tests with defined min and max value |
|||
PASSED: range min = 10 max = 100 |
|||
PASSED: range min = 100 max = 1000 |
|||
PASSED: range min = 10 max = 19 |
|||
PASSED: range min = 10500 max = 1050000 |
|||
PASSED: range min = 16 max = 65536 |
|||
PASSED: range min = 256 max = 448 |
|||
|
|||
Non-numeric cases |
|||
PASSED range min = 1 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 10 max = 100 |
|||
PASSED range min = 0 max = 100 |
|||
PASSED range min = 10 max = 100 |
|||
@ -0,0 +1,18 @@ |
|||
--TEST-- |
|||
Test rand() - wrong params test rand() |
|||
--FILE-- |
|||
<?php |
|||
rand(25); |
|||
rand(10,100,false); |
|||
rand("one", 100); |
|||
rand(1, "hundered"); |
|||
?> |
|||
--EXPECTF-- |
|||
|
|||
Warning: rand() expects exactly 2 parameters, 1 given in %s on line 2 |
|||
|
|||
Warning: rand() expects exactly 2 parameters, 3 given in %s on line 3 |
|||
|
|||
Warning: rand() expects parameter 1 to be long, string given in %s on line 4 |
|||
|
|||
Warning: rand() expects parameter 2 to be long, string given in %s on line 5 |
|||
@ -0,0 +1,18 @@ |
|||
--TEST-- |
|||
Test return type and value for expected input sqrt() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float sqrt(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$arg_0 = 9.0; |
|||
|
|||
var_dump(sqrt($arg_0)); |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
float(3) |
|||
@ -0,0 +1,31 @@ |
|||
--TEST-- |
|||
Test wrong number of arguments for sqrt() |
|||
--INI-- |
|||
precision = 14 |
|||
--FILE-- |
|||
<?php |
|||
/* |
|||
* proto float sqrt(float number) |
|||
* Function is implemented in ext/standard/math.c |
|||
*/ |
|||
|
|||
$arg_0 = 1.0; |
|||
$extra_arg = 1; |
|||
|
|||
echo "\nToo many arguments\n"; |
|||
var_dump(sqrt($arg_0, $extra_arg)); |
|||
|
|||
echo "\nToo few arguments\n"; |
|||
var_dump(sqrt()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Too many arguments |
|||
|
|||
Warning: Wrong parameter count for sqrt() in %s on line 11 |
|||
NULL |
|||
|
|||
Too few arguments |
|||
|
|||
Warning: Wrong parameter count for sqrt() in %s on line 14 |
|||
NULL |
|||
@ -0,0 +1,24 @@ |
|||
--TEST-- |
|||
Maths test for xapic versions of srand() |
|||
--FILE-- |
|||
<?php |
|||
// Should return NULL if given anything that it can convert to long |
|||
// This doesn't actually test what it does with the input :-\ |
|||
var_dump(srand()); |
|||
var_dump(srand(500)); |
|||
var_dump(srand(500.1)); |
|||
var_dump(srand("500")); |
|||
var_dump(srand("500E3")); |
|||
var_dump(srand(true)); |
|||
var_dump(srand(false)); |
|||
var_dump(srand(NULL)); |
|||
?> |
|||
--EXPECTF-- |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
NULL |
|||
@ -0,0 +1,17 @@ |
|||
--TEST-- |
|||
Test srand() - wrong params test srand() |
|||
--FILE-- |
|||
<?php |
|||
var_dump(mt_srand(500, true)); |
|||
var_dump(mt_srand("fivehundred")); |
|||
var_dump(mt_srand("500ABC")); |
|||
?> |
|||
--EXPECTF-- |
|||
Warning: mt_srand() expects at most 1 parameter, 2 given in %s on line 2 |
|||
NULL |
|||
|
|||
Warning: mt_srand() expects parameter 1 to be long, string given in %s on line 3 |
|||
NULL |
|||
|
|||
Notice: A non well formed numeric value encountered in %s on line 4 |
|||
NULL |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue