From 44b091a30da18685d9145bf5d0f7bfff5de95956 Mon Sep 17 00:00:00 2001 From: Zoe Slattery Date: Wed, 6 Feb 2008 09:51:19 +0000 Subject: [PATCH] Tests for assorted Maths functions --- ext/standard/tests/math/dechex_basic.phpt | 38 ++++ ext/standard/tests/math/dechex_error.phpt | 13 ++ ext/standard/tests/math/decoct_basic.phpt | 38 ++++ ext/standard/tests/math/decoct_error.phpt | 13 ++ ext/standard/tests/math/deg2rad_basic.phpt | 67 ++++++ ext/standard/tests/math/deg2rad_error.phpt | 31 +++ .../tests/math/deg2rad_variation.phpt | 52 +++++ ext/standard/tests/math/exp_error.phpt | 14 ++ ext/standard/tests/math/fmod_basic.phpt | 209 ++++++++++++++++++ ext/standard/tests/math/fmod_error.phpt | 17 ++ ext/standard/tests/math/getrandmax_basic.phpt | 9 + ext/standard/tests/math/getrandmax_error.phpt | 9 + ext/standard/tests/math/hexdec_basic.phpt | 46 ++++ ext/standard/tests/math/hexdec_error.phpt | 12 + ext/standard/tests/math/hypot_error.phpt | 18 ++ ext/standard/tests/math/is_finite_basic.phpt | 41 ++++ ext/standard/tests/math/is_finite_error.phpt | 13 ++ .../tests/math/is_infinite_basic.phpt | 42 ++++ .../tests/math/is_infinite_error.phpt | 12 + ext/standard/tests/math/is_nan_basic.phpt | 45 ++++ ext/standard/tests/math/is_nan_error.phpt | 16 ++ ext/standard/tests/math/lcg_value_basic.phpt | 56 +++++ ext/standard/tests/math/log10_basic.phpt | 55 +++++ ext/standard/tests/math/log10_error.phpt | 31 +++ ext/standard/tests/math/log10_variation.phpt | 52 +++++ ext/standard/tests/math/log_basic.phpt | 60 +++++ ext/standard/tests/math/log_error.phpt | 17 ++ .../tests/math/mt_getrandmax_basic.phpt | 8 + .../tests/math/mt_getrandmax_error.phpt | 9 + ext/standard/tests/math/mt_rand_basic.phpt | 102 +++++++++ ext/standard/tests/math/mt_rand_error.phpt | 19 ++ ext/standard/tests/math/mt_srand_basic.phpt | 24 ++ ext/standard/tests/math/mt_srand_error.phpt | 20 ++ .../tests/math/number_format_error.phpt | 16 ++ ext/standard/tests/math/octdec_basic.phpt | 45 ++++ ext/standard/tests/math/octdec_error.phpt | 12 + ext/standard/tests/math/pi_basic.phpt | 14 ++ ext/standard/tests/math/pow_basic.phpt | 37 ++++ ext/standard/tests/math/pow_error.phpt | 19 ++ ext/standard/tests/math/rad2deg_basic.phpt | 65 ++++++ ext/standard/tests/math/rad2deg_error.phpt | 31 +++ .../tests/math/rad2deg_variation.phpt | 52 +++++ ext/standard/tests/math/rand_basic.phpt | 103 +++++++++ ext/standard/tests/math/rand_error.phpt | 18 ++ ext/standard/tests/math/sqrt_basic.phpt | 18 ++ ext/standard/tests/math/sqrt_error.phpt | 31 +++ ext/standard/tests/math/srand_basic.phpt | 24 ++ ext/standard/tests/math/srand_error.phpt | 17 ++ 48 files changed, 1710 insertions(+) create mode 100644 ext/standard/tests/math/dechex_basic.phpt create mode 100644 ext/standard/tests/math/dechex_error.phpt create mode 100644 ext/standard/tests/math/decoct_basic.phpt create mode 100644 ext/standard/tests/math/decoct_error.phpt create mode 100644 ext/standard/tests/math/deg2rad_basic.phpt create mode 100644 ext/standard/tests/math/deg2rad_error.phpt create mode 100644 ext/standard/tests/math/deg2rad_variation.phpt create mode 100644 ext/standard/tests/math/exp_error.phpt create mode 100644 ext/standard/tests/math/fmod_basic.phpt create mode 100644 ext/standard/tests/math/fmod_error.phpt create mode 100644 ext/standard/tests/math/getrandmax_basic.phpt create mode 100644 ext/standard/tests/math/getrandmax_error.phpt create mode 100644 ext/standard/tests/math/hexdec_basic.phpt create mode 100644 ext/standard/tests/math/hexdec_error.phpt create mode 100644 ext/standard/tests/math/hypot_error.phpt create mode 100644 ext/standard/tests/math/is_finite_basic.phpt create mode 100644 ext/standard/tests/math/is_finite_error.phpt create mode 100644 ext/standard/tests/math/is_infinite_basic.phpt create mode 100644 ext/standard/tests/math/is_infinite_error.phpt create mode 100644 ext/standard/tests/math/is_nan_basic.phpt create mode 100644 ext/standard/tests/math/is_nan_error.phpt create mode 100644 ext/standard/tests/math/lcg_value_basic.phpt create mode 100644 ext/standard/tests/math/log10_basic.phpt create mode 100644 ext/standard/tests/math/log10_error.phpt create mode 100644 ext/standard/tests/math/log10_variation.phpt create mode 100644 ext/standard/tests/math/log_basic.phpt create mode 100644 ext/standard/tests/math/log_error.phpt create mode 100644 ext/standard/tests/math/mt_getrandmax_basic.phpt create mode 100644 ext/standard/tests/math/mt_getrandmax_error.phpt create mode 100644 ext/standard/tests/math/mt_rand_basic.phpt create mode 100644 ext/standard/tests/math/mt_rand_error.phpt create mode 100644 ext/standard/tests/math/mt_srand_basic.phpt create mode 100644 ext/standard/tests/math/mt_srand_error.phpt create mode 100644 ext/standard/tests/math/number_format_error.phpt create mode 100644 ext/standard/tests/math/octdec_basic.phpt create mode 100644 ext/standard/tests/math/octdec_error.phpt create mode 100644 ext/standard/tests/math/pi_basic.phpt create mode 100644 ext/standard/tests/math/pow_basic.phpt create mode 100644 ext/standard/tests/math/pow_error.phpt create mode 100644 ext/standard/tests/math/rad2deg_basic.phpt create mode 100644 ext/standard/tests/math/rad2deg_error.phpt create mode 100644 ext/standard/tests/math/rad2deg_variation.phpt create mode 100644 ext/standard/tests/math/rand_basic.phpt create mode 100644 ext/standard/tests/math/rand_error.phpt create mode 100644 ext/standard/tests/math/sqrt_basic.phpt create mode 100644 ext/standard/tests/math/sqrt_error.phpt create mode 100644 ext/standard/tests/math/srand_basic.phpt create mode 100644 ext/standard/tests/math/srand_error.phpt diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt new file mode 100644 index 0000000000..cba4aa632e --- /dev/null +++ b/ext/standard/tests/math/dechex_basic.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test dechex() - basic function dechex() +--FILE-- + +--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" \ No newline at end of file diff --git a/ext/standard/tests/math/dechex_error.phpt b/ext/standard/tests/math/dechex_error.phpt new file mode 100644 index 0000000000..f83afb346a --- /dev/null +++ b/ext/standard/tests/math/dechex_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test dechex() - wrong params dechex() +--FILE-- + + +--EXPECTF-- + +Warning: Wrong parameter count for dechex() in %s on line 2 + +Warning: Wrong parameter count for dechex() in %s on line 3 diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt new file mode 100644 index 0000000000..3021e6be1d --- /dev/null +++ b/ext/standard/tests/math/decoct_basic.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test decoct() - basic function test decoct() +--FILE-- + +--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" diff --git a/ext/standard/tests/math/decoct_error.phpt b/ext/standard/tests/math/decoct_error.phpt new file mode 100644 index 0000000000..48c30644fe --- /dev/null +++ b/ext/standard/tests/math/decoct_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test decoct() - wrong params decoct() +--FILE-- + +--EXPECTF-- + +Warning: Wrong parameter count for decoct() in %s on line 2 + +Warning: Wrong parameter count for decoct() in %s on line 3 + diff --git a/ext/standard/tests/math/deg2rad_basic.phpt b/ext/standard/tests/math/deg2rad_basic.phpt new file mode 100644 index 0000000000..64771b9980 --- /dev/null +++ b/ext/standard/tests/math/deg2rad_basic.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test return type and value for expected input deg2rad() +--INI-- +precision = 14 +--FILE-- + +--EXPECTF-- +deg2rad 0 = float(%f) +Pass +deg2rad 90 = float(%f) +Pass +deg2rad 180 = float(%f) +Pass +deg2rad 360 = float(%f) +Pass diff --git a/ext/standard/tests/math/deg2rad_error.phpt b/ext/standard/tests/math/deg2rad_error.phpt new file mode 100644 index 0000000000..3cfdfc3044 --- /dev/null +++ b/ext/standard/tests/math/deg2rad_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test wrong number of arguments for deg2rad() +--INI-- +precision = 14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/deg2rad_variation.phpt b/ext/standard/tests/math/deg2rad_variation.phpt new file mode 100644 index 0000000000..4ce8900a9f --- /dev/null +++ b/ext/standard/tests/math/deg2rad_variation.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test variations in usage of deg2rad() +--INI-- +precision = 10 +--FILE-- + +--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) diff --git a/ext/standard/tests/math/exp_error.phpt b/ext/standard/tests/math/exp_error.phpt new file mode 100644 index 0000000000..f65743475c --- /dev/null +++ b/ext/standard/tests/math/exp_error.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test exp() - wrong params for exp() +--INI-- +precision=14 +--FILE-- + +--EXPECTF-- + +Warning: Wrong parameter count for exp() in %s on line 2 + +Warning: Wrong parameter count for exp() in %s on line 3 diff --git a/ext/standard/tests/math/fmod_basic.phpt b/ext/standard/tests/math/fmod_basic.phpt new file mode 100644 index 0000000000..c29abca9d2 --- /dev/null +++ b/ext/standard/tests/math/fmod_basic.phpt @@ -0,0 +1,209 @@ +--TEST-- +Test fmod() - basic function test fmod() +--INI-- +precision=14 +--FILE-- + +--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) diff --git a/ext/standard/tests/math/fmod_error.phpt b/ext/standard/tests/math/fmod_error.phpt new file mode 100644 index 0000000000..42a6ad1a02 --- /dev/null +++ b/ext/standard/tests/math/fmod_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test fmod() - wrong params test fmod() +--INI-- +precision=14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/getrandmax_basic.phpt b/ext/standard/tests/math/getrandmax_basic.phpt new file mode 100644 index 0000000000..4e52c192d8 --- /dev/null +++ b/ext/standard/tests/math/getrandmax_basic.phpt @@ -0,0 +1,9 @@ +--TEST-- +Test getrandmax() - basic function test getrandmax() +--FILE-- + +--EXPECTF-- +int(%d) \ No newline at end of file diff --git a/ext/standard/tests/math/getrandmax_error.phpt b/ext/standard/tests/math/getrandmax_error.phpt new file mode 100644 index 0000000000..9f244a2a6a --- /dev/null +++ b/ext/standard/tests/math/getrandmax_error.phpt @@ -0,0 +1,9 @@ +--TEST-- +Test getrandmax() - wrong params test getrandmax() +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for getrandmax() in %s on line 2 +NULL diff --git a/ext/standard/tests/math/hexdec_basic.phpt b/ext/standard/tests/math/hexdec_basic.phpt new file mode 100644 index 0000000000..d1da737141 --- /dev/null +++ b/ext/standard/tests/math/hexdec_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test hexdec() - basic function test hexdec() +--FILE-- + +--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) diff --git a/ext/standard/tests/math/hexdec_error.phpt b/ext/standard/tests/math/hexdec_error.phpt new file mode 100644 index 0000000000..06ce3fb20d --- /dev/null +++ b/ext/standard/tests/math/hexdec_error.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test hexdec() - wrong params test hexdec() +--FILE-- + +--EXPECTF-- + +Warning: Wrong parameter count for hexdec() in %s on line 2 + +Warning: Wrong parameter count for hexdec() in %s on line 3 diff --git a/ext/standard/tests/math/hypot_error.phpt b/ext/standard/tests/math/hypot_error.phpt new file mode 100644 index 0000000000..19a9ee0852 --- /dev/null +++ b/ext/standard/tests/math/hypot_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test hypot() - wrong params test hypot() +--INI-- +precision=14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/is_finite_basic.phpt b/ext/standard/tests/math/is_finite_basic.phpt new file mode 100644 index 0000000000..85d2685273 --- /dev/null +++ b/ext/standard/tests/math/is_finite_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test is_finite() - basic function test is_finite() +--FILE-- + +--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) + + diff --git a/ext/standard/tests/math/is_finite_error.phpt b/ext/standard/tests/math/is_finite_error.phpt new file mode 100644 index 0000000000..e26563079e --- /dev/null +++ b/ext/standard/tests/math/is_finite_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test is_finite() - wrong params test is_finite() +--FILE-- + +--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 + diff --git a/ext/standard/tests/math/is_infinite_basic.phpt b/ext/standard/tests/math/is_infinite_basic.phpt new file mode 100644 index 0000000000..ca79922287 --- /dev/null +++ b/ext/standard/tests/math/is_infinite_basic.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test is_infinite() - basic function test is_infinite() +--FILE-- + +--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) + + + diff --git a/ext/standard/tests/math/is_infinite_error.phpt b/ext/standard/tests/math/is_infinite_error.phpt new file mode 100644 index 0000000000..5d6ad9d42c --- /dev/null +++ b/ext/standard/tests/math/is_infinite_error.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test is_infinite() - wrong params test is_infinite() +--FILE-- + +--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 diff --git a/ext/standard/tests/math/is_nan_basic.phpt b/ext/standard/tests/math/is_nan_basic.phpt new file mode 100644 index 0000000000..fb10737cea --- /dev/null +++ b/ext/standard/tests/math/is_nan_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test is_nan() - basic function test is_nan() +--FILE-- + + +--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) + + + diff --git a/ext/standard/tests/math/is_nan_error.phpt b/ext/standard/tests/math/is_nan_error.phpt new file mode 100644 index 0000000000..7749e4e406 --- /dev/null +++ b/ext/standard/tests/math/is_nan_error.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test is_nan() - wrong params test is_nan() +--FILE-- + +--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 + + + + diff --git a/ext/standard/tests/math/lcg_value_basic.phpt b/ext/standard/tests/math/lcg_value_basic.phpt new file mode 100644 index 0000000000..6d624d84ab --- /dev/null +++ b/ext/standard/tests/math/lcg_value_basic.phpt @@ -0,0 +1,56 @@ +--TEST-- +Maths test for xapic versions of lcg_value() +--FILE-- + 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 + + + diff --git a/ext/standard/tests/math/log10_basic.phpt b/ext/standard/tests/math/log10_basic.phpt new file mode 100644 index 0000000000..0877df23d7 --- /dev/null +++ b/ext/standard/tests/math/log10_basic.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test return type and value for expected input log10() +--INI-- +precision = 14 +--FILE-- + +--EXPECTF-- +log10 1 = float(%f) +Pass +log10 10 = float(%f) +Pass +log10 100 = float(%f) +Pass diff --git a/ext/standard/tests/math/log10_error.phpt b/ext/standard/tests/math/log10_error.phpt new file mode 100644 index 0000000000..083494a84a --- /dev/null +++ b/ext/standard/tests/math/log10_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test wrong number of arguments for log10() +--INI-- +precision = 14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/log10_variation.phpt b/ext/standard/tests/math/log10_variation.phpt new file mode 100644 index 0000000000..746412a44e --- /dev/null +++ b/ext/standard/tests/math/log10_variation.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test variations in usage of log10() +--INI-- +precision = 10 +--FILE-- + +--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) diff --git a/ext/standard/tests/math/log_basic.phpt b/ext/standard/tests/math/log_basic.phpt new file mode 100644 index 0000000000..e2f9c9fe7d --- /dev/null +++ b/ext/standard/tests/math/log_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test log() - basic function test log() +--INI-- +precision=14 +--FILE-- + + +--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) diff --git a/ext/standard/tests/math/log_error.phpt b/ext/standard/tests/math/log_error.phpt new file mode 100644 index 0000000000..77084a4eca --- /dev/null +++ b/ext/standard/tests/math/log_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test log() - wrong params test log() +--INI-- +precision=14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/mt_getrandmax_basic.phpt b/ext/standard/tests/math/mt_getrandmax_basic.phpt new file mode 100644 index 0000000000..29a30d088f --- /dev/null +++ b/ext/standard/tests/math/mt_getrandmax_basic.phpt @@ -0,0 +1,8 @@ +--TEST-- +Test mt_getrandmax() - basic function test mt_getrandmax() +--FILE-- + +--EXPECTF-- +int(%d) \ No newline at end of file diff --git a/ext/standard/tests/math/mt_getrandmax_error.phpt b/ext/standard/tests/math/mt_getrandmax_error.phpt new file mode 100644 index 0000000000..b30da3a91c --- /dev/null +++ b/ext/standard/tests/math/mt_getrandmax_error.phpt @@ -0,0 +1,9 @@ +--TEST-- +Test mt_getrandmax() - wrong paramas mt_getrandmax() +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for mt_getrandmax() in %s on line 2 +NULL \ No newline at end of file diff --git a/ext/standard/tests/math/mt_rand_basic.phpt b/ext/standard/tests/math/mt_rand_basic.phpt new file mode 100644 index 0000000000..8b6b3cb2ce --- /dev/null +++ b/ext/standard/tests/math/mt_rand_basic.phpt @@ -0,0 +1,102 @@ +--TEST-- +Test mt_rand() - basic function test mt_rand() +--FILE-- + $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 diff --git a/ext/standard/tests/math/mt_rand_error.phpt b/ext/standard/tests/math/mt_rand_error.phpt new file mode 100644 index 0000000000..e0a80586ef --- /dev/null +++ b/ext/standard/tests/math/mt_rand_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test mt_rand() - wrong params test mt_rand() +--FILE-- + + +--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 diff --git a/ext/standard/tests/math/mt_srand_basic.phpt b/ext/standard/tests/math/mt_srand_basic.phpt new file mode 100644 index 0000000000..e28b1b9eae --- /dev/null +++ b/ext/standard/tests/math/mt_srand_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test mt_srand() - basic function (return values) mt_srand() +--FILE-- + +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL \ No newline at end of file diff --git a/ext/standard/tests/math/mt_srand_error.phpt b/ext/standard/tests/math/mt_srand_error.phpt new file mode 100644 index 0000000000..5543d78410 --- /dev/null +++ b/ext/standard/tests/math/mt_srand_error.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test mt_srand() - wrong params test mt_srand() +--FILE-- + +--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 + + + diff --git a/ext/standard/tests/math/number_format_error.phpt b/ext/standard/tests/math/number_format_error.phpt new file mode 100644 index 0000000000..5ebe129312 --- /dev/null +++ b/ext/standard/tests/math/number_format_error.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test number_format() - wrong params test number_format() +--FILE-- + +--EXPECTF-- + +Warning: Wrong parameter count for number_format() in %s on line 2 + +Warning: Wrong parameter count for number_format() in %s on line 3 + +Warning: Wrong parameter count for number_format() in %s on line 4 + diff --git a/ext/standard/tests/math/octdec_basic.phpt b/ext/standard/tests/math/octdec_basic.phpt new file mode 100644 index 0000000000..5412bd8bab --- /dev/null +++ b/ext/standard/tests/math/octdec_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test octdec() - basic function test octdec() +--FILE-- + +--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) \ No newline at end of file diff --git a/ext/standard/tests/math/octdec_error.phpt b/ext/standard/tests/math/octdec_error.phpt new file mode 100644 index 0000000000..8a3d1759a3 --- /dev/null +++ b/ext/standard/tests/math/octdec_error.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test octdec() - wrong params test octdec() +--FILE-- + +--EXPECTF-- + +Warning: Wrong parameter count for octdec() in %s on line 2 + +Warning: Wrong parameter count for octdec() in %s on line 3 diff --git a/ext/standard/tests/math/pi_basic.phpt b/ext/standard/tests/math/pi_basic.phpt new file mode 100644 index 0000000000..fec5691371 --- /dev/null +++ b/ext/standard/tests/math/pi_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test pi() - basic function test pi() +--INI-- +precision=14 +--FILE-- + +--EXPECTF-- +3.1415926535898 +3.1415926535898 diff --git a/ext/standard/tests/math/pow_basic.phpt b/ext/standard/tests/math/pow_basic.phpt new file mode 100644 index 0000000000..96864e0abc --- /dev/null +++ b/ext/standard/tests/math/pow_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test pow() - basic function test pow() +--INI-- +precision=14 +--FILE-- + +--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) \ No newline at end of file diff --git a/ext/standard/tests/math/pow_error.phpt b/ext/standard/tests/math/pow_error.phpt new file mode 100644 index 0000000000..d00173eb48 --- /dev/null +++ b/ext/standard/tests/math/pow_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test pow() - wrong params test pow() +--INI-- +precision=14 +--FILE-- + +--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 + + diff --git a/ext/standard/tests/math/rad2deg_basic.phpt b/ext/standard/tests/math/rad2deg_basic.phpt new file mode 100644 index 0000000000..0256ffbd90 --- /dev/null +++ b/ext/standard/tests/math/rad2deg_basic.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test return type and value for expected input rad2deg() +--INI-- +precision = 14 +--FILE-- + +--EXPECTF-- +rad2deg 0= float(%f) +Pass +rad2deg 1.570796327 = float(%f) +Pass +rad2deg 3.141592654 = float(%f) +Pass +rad2deg 6.283185307 = float(%f) +Pass diff --git a/ext/standard/tests/math/rad2deg_error.phpt b/ext/standard/tests/math/rad2deg_error.phpt new file mode 100644 index 0000000000..9892321068 --- /dev/null +++ b/ext/standard/tests/math/rad2deg_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test wrong number of arguments for rad2deg() +--INI-- +precision = 14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/rad2deg_variation.phpt b/ext/standard/tests/math/rad2deg_variation.phpt new file mode 100644 index 0000000000..3fd6ec8cf3 --- /dev/null +++ b/ext/standard/tests/math/rad2deg_variation.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test variations in usage of rad2deg() +--INI-- +precision = 10 +--FILE-- + +--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) diff --git a/ext/standard/tests/math/rand_basic.phpt b/ext/standard/tests/math/rand_basic.phpt new file mode 100644 index 0000000000..525956017e --- /dev/null +++ b/ext/standard/tests/math/rand_basic.phpt @@ -0,0 +1,103 @@ +--TEST-- +Test rand() - basic function test rand() +--FILE-- + $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 diff --git a/ext/standard/tests/math/rand_error.phpt b/ext/standard/tests/math/rand_error.phpt new file mode 100644 index 0000000000..79aa0112d3 --- /dev/null +++ b/ext/standard/tests/math/rand_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test rand() - wrong params test rand() +--FILE-- + +--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 diff --git a/ext/standard/tests/math/sqrt_basic.phpt b/ext/standard/tests/math/sqrt_basic.phpt new file mode 100644 index 0000000000..076a113016 --- /dev/null +++ b/ext/standard/tests/math/sqrt_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test return type and value for expected input sqrt() +--INI-- +precision = 14 +--FILE-- + +--EXPECT-- +float(3) diff --git a/ext/standard/tests/math/sqrt_error.phpt b/ext/standard/tests/math/sqrt_error.phpt new file mode 100644 index 0000000000..318a18a35a --- /dev/null +++ b/ext/standard/tests/math/sqrt_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test wrong number of arguments for sqrt() +--INI-- +precision = 14 +--FILE-- + +--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 diff --git a/ext/standard/tests/math/srand_basic.phpt b/ext/standard/tests/math/srand_basic.phpt new file mode 100644 index 0000000000..16aa2dd69e --- /dev/null +++ b/ext/standard/tests/math/srand_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +Maths test for xapic versions of srand() +--FILE-- + +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL \ No newline at end of file diff --git a/ext/standard/tests/math/srand_error.phpt b/ext/standard/tests/math/srand_error.phpt new file mode 100644 index 0000000000..8528672221 --- /dev/null +++ b/ext/standard/tests/math/srand_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test srand() - wrong params test srand() +--FILE-- + +--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 -- 2.50.1