diff options
author | Zoe Slattery <zoe@php.net> | 2007-09-04 11:18:35 +0000 |
---|---|---|
committer | Zoe Slattery <zoe@php.net> | 2007-09-04 11:18:35 +0000 |
commit | 8e59bf05cb0095f19a36799126729f623ce53ee0 (patch) | |
tree | 17c00b5e4e659bbb5154c7fed357cb290bf18f12 /ext/standard | |
parent | 81313aed39ed3af2bbde2addae79d0990fea14dd (diff) | |
download | php-git-8e59bf05cb0095f19a36799126729f623ce53ee0.tar.gz |
Test cases for sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh.
Diffstat (limited to 'ext/standard')
37 files changed, 2039 insertions, 0 deletions
diff --git a/ext/standard/tests/math/acos_basic.phpt b/ext/standard/tests/math/acos_basic.phpt new file mode 100644 index 0000000000..150eb975ad --- /dev/null +++ b/ext/standard/tests/math/acos_basic.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test return type and value for expected input acos() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float acos(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + + +//output is in degrees + +echo "acos .5 = "; +$acosv1 = 360.0 * acos(0.5) / (2.0 * M_PI ); +var_dump($acosv1); +if (allowed_rounding_error($acosv1 ,60 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "acos 0.86602540378444 = "; +$acosv2 = 360.0 * acos(0.86602540378444) / (2.0 * M_PI ); +var_dump($acosv2); +if (allowed_rounding_error($acosv2 ,30 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + + +echo "acos 1.0 = "; +$acosv3 = 360.0 * acos(1.0) / (2.0 * M_PI); +var_dump($acosv3); +if (allowed_rounding_error($acosv3 ,0 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + + +echo "acos 0.0 = "; +$acosv4 = 360.0 * acos(0.0) / (2.0 * M_PI ); +var_dump($acosv4); +if (allowed_rounding_error($acosv3 ,0 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +acos .5 = float(%f) +Pass +acos 0.86602540378444 = float(%f) +Pass +acos 1.0 = float(%f) +Pass +acos 0.0 = float(%f) +Pass diff --git a/ext/standard/tests/math/acos_error.phpt b/ext/standard/tests/math/acos_error.phpt new file mode 100644 index 0000000000..0b34a9b779 --- /dev/null +++ b/ext/standard/tests/math/acos_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for acos() +--INI-- +--FILE-- +<?php +/* + * proto float acos(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(acos($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(acos()); + +?> +--EXPECTF-- +Too many arguments + +Warning: acos() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: acos() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/acos_variation.phpt b/ext/standard/tests/math/acos_variation.phpt new file mode 100644 index 0000000000..ecc2dc243d --- /dev/null +++ b/ext/standard/tests/math/acos_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of acos() +--INI-- +precision=10 +--FILE-- +<?php +/* + * proto float acos(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test acos 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 = acos($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: acos() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(1.570796327) +float(0) +float(1.570796327) +--UEXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: acos() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(1.570796327) +float(0) +float(1.570796327) diff --git a/ext/standard/tests/math/acosh_basic.phpt b/ext/standard/tests/math/acosh_basic.phpt new file mode 100644 index 0000000000..34839ee2fd --- /dev/null +++ b/ext/standard/tests/math/acosh_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test return type and value for expected input acosh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float acosh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "acosh 1.1276259652064= "; +var_dump(acosh(1.1276259652064)); +if (allowed_rounding_error(acosh(1.1276259652064), 0.5)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "acosh 10.067661995778= "; +var_dump(acosh(10.067661995778)); +if (allowed_rounding_error(acosh(10.067661995778), 3.0)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + + +?> +--EXPECTF-- +acosh 1.1276259652064= float(%f) +Pass +acosh 10.067661995778= float(%f) +Pass diff --git a/ext/standard/tests/math/acosh_error.phpt b/ext/standard/tests/math/acosh_error.phpt new file mode 100644 index 0000000000..8c95fc5172 --- /dev/null +++ b/ext/standard/tests/math/acosh_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test wrong number of arguments for acosh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +--FILE-- +<?php +/* + * proto float acosh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(acosh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(acosh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: acosh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: acosh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/acosh_variation.phpt b/ext/standard/tests/math/acosh_variation.phpt new file mode 100644 index 0000000000..f166a4753a --- /dev/null +++ b/ext/standard/tests/math/acosh_variation.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test variations in usage of acosh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float acosh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test acosh 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 = acosh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(3.828168471) +float(NAN) +float(3.847562739) +float(NAN) +float(3.828168471) +float(3.828168471) +float(3.828168471) +float(3.847562739) +float(3.847562739) + +Warning: acosh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(7.60090221) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(7.60090221) +float(NAN) +float(0) +float(NAN) +--UEXPECTF-- +float(3.828168471) +float(NAN) +float(3.847562739) +float(NAN) +float(3.828168471) +float(3.828168471) +float(3.828168471) +float(3.847562739) +float(3.847562739) + +Warning: acosh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(7.60090221) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(7.60090221) +float(NAN) +float(0) +float(NAN) diff --git a/ext/standard/tests/math/allowed_rounding_error.inc b/ext/standard/tests/math/allowed_rounding_error.inc new file mode 100644 index 0000000000..71dbf9af4a --- /dev/null +++ b/ext/standard/tests/math/allowed_rounding_error.inc @@ -0,0 +1,18 @@ +<?php +function allowed_rounding_error ($number, $expected) { + + //different machines may give slightly different floating point numbers + //This assumes that the results will be the same to + or - 1.0E-10. + + $small_number = 1.0e-10; + $min = $expected - $small_number; + $max = $expected + $small_number; + + if ($number < $max && $number > $min ) { + return true; + } + else { + return false; + } +} +?>
\ No newline at end of file diff --git a/ext/standard/tests/math/asin_basic.phpt b/ext/standard/tests/math/asin_basic.phpt new file mode 100644 index 0000000000..183f7449bb --- /dev/null +++ b/ext/standard/tests/math/asin_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test return type and value for expected input asin() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float asin(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + + +//output is in degrees + +echo "asin .5 = "; +$asinv1 = 360.0 * asin(0.5) / (2.0 * M_PI ); +var_dump($asinv1); +if (allowed_rounding_error($asinv1 ,30 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "asin 0.86602540378444 = "; +$asinv2 = 360.0 * asin(0.86602540378444) / (2.0 * M_PI ); +var_dump($asinv2); +if (allowed_rounding_error($asinv2 ,60 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "asin 1.0 = "; +$asinv3 = 360.0 * asin(1.0) / (2.0 * M_PI ); +var_dump($asinv3); +if (allowed_rounding_error($asinv3 ,90 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + + +echo "asin 0.0 = "; +$asinv4 = 360.0 * asin(0.0) / (2.0 * M_PI ); +var_dump($asinv4); +if (allowed_rounding_error($asinv4 ,0 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +asin .5 = float(%f) +Pass +asin 0.86602540378444 = float(%f) +Pass +asin 1.0 = float(%f) +Pass +asin 0.0 = float(%f) +Pass diff --git a/ext/standard/tests/math/asin_error.phpt b/ext/standard/tests/math/asin_error.phpt new file mode 100644 index 0000000000..e7bfebc6b9 --- /dev/null +++ b/ext/standard/tests/math/asin_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for asin() +--INI-- +--FILE-- +<?php +/* + * proto float asin(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(asin($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(asin()); + +?> +--EXPECTF-- +Too many arguments + +Warning: asin() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: asin() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/asin_variation.phpt b/ext/standard/tests/math/asin_variation.phpt new file mode 100644 index 0000000000..0a14f43818 --- /dev/null +++ b/ext/standard/tests/math/asin_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of asin() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float asin(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test asin 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 = asin($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: asin() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(0) +float(1.570796327) +float(0) +--UEXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: asin() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(0) +float(1.570796327) +float(0) diff --git a/ext/standard/tests/math/asinh_basic.phpt b/ext/standard/tests/math/asinh_basic.phpt new file mode 100644 index 0000000000..61f1731553 --- /dev/null +++ b/ext/standard/tests/math/asinh_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test return type and value for expected input asinh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float asinh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "asinh 0.52109530549375= "; +var_dump(asinh(0.52109530549375)); +if (allowed_rounding_error(asinh(0.52109530549375), 0.5)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "asinh 10.01787492741= "; +var_dump(asinh(10.01787492741)); +if (allowed_rounding_error(asinh(10.01787492741), 3.0)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +asinh 0.52109530549375= float(%f) +Pass +asinh 10.01787492741= float(%f) +Pass diff --git a/ext/standard/tests/math/asinh_error.phpt b/ext/standard/tests/math/asinh_error.phpt new file mode 100644 index 0000000000..2cea6ed073 --- /dev/null +++ b/ext/standard/tests/math/asinh_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test wrong number of arguments for asinh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +--FILE-- +<?php +/* + * proto float asinh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(asinh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(asinh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: asinh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: asinh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/asinh_variation.phpt b/ext/standard/tests/math/asinh_variation.phpt new file mode 100644 index 0000000000..aae658dd74 --- /dev/null +++ b/ext/standard/tests/math/asinh_variation.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test variations in usage of asinh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float asinh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test asinh 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 = asinh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(3.829113652) +float(-3.829113652) +float(3.848471992) +float(-3.848471992) +float(3.829113652) +float(3.829113652) +float(3.829113652) +float(3.848471992) +float(3.848471992) + +Warning: asinh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(7.60090271) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(7.60090271) +float(0) +float(0.881373587) +float(0) +--UEXPECTF-- +float(3.829113652) +float(-3.829113652) +float(3.848471992) +float(-3.848471992) +float(3.829113652) +float(3.829113652) +float(3.829113652) +float(3.848471992) +float(3.848471992) + +Warning: asinh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(7.60090271) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(7.60090271) +float(0) +float(0.881373587) +float(0) diff --git a/ext/standard/tests/math/atan_basic.phpt b/ext/standard/tests/math/atan_basic.phpt new file mode 100644 index 0000000000..f4a2bedf76 --- /dev/null +++ b/ext/standard/tests/math/atan_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test return type and value for expected input atan() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float atan(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "atan 1.7320508075689 = "; +$atan1 = 360 * atan(1.7320508075689) / (2.0 * M_PI); +var_dump($atan1); +if (allowed_rounding_error($atan1 ,60 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "atan 0.57735026918963 = "; +$atan2 = 360 * atan(0.57735026918963) / (2.0 * M_PI); +var_dump($atan2); +if (allowed_rounding_error($atan2 ,30 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +atan 1.7320508075689 = float(%f) +Pass +atan 0.57735026918963 = float(%f) +Pass diff --git a/ext/standard/tests/math/atan_error.phpt b/ext/standard/tests/math/atan_error.phpt new file mode 100644 index 0000000000..052743fedf --- /dev/null +++ b/ext/standard/tests/math/atan_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for atan() +--INI-- +--FILE-- +<?php +/* + * proto float atan(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(atan($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(atan()); + +?> +--EXPECTF-- +Too many arguments + +Warning: atan() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: atan() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/atan_variation.phpt b/ext/standard/tests/math/atan_variation.phpt new file mode 100644 index 0000000000..de12f2cc1a --- /dev/null +++ b/ext/standard/tests/math/atan_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of atan() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float atan(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test atan 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 = atan($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(1.527345431) +float(-1.527345431) +float(1.528178225) +float(-1.528178225) +float(1.527345431) +float(1.527345431) +float(1.527345431) +float(1.528178225) +float(1.528178225) + +Warning: atan() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(1.569796327) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1.569796327) +float(0) +float(0.7853981634) +float(0) +--UEXPECTF-- +float(1.527345431) +float(-1.527345431) +float(1.528178225) +float(-1.528178225) +float(1.527345431) +float(1.527345431) +float(1.527345431) +float(1.528178225) +float(1.528178225) + +Warning: atan() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(1.569796327) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1.569796327) +float(0) +float(0.7853981634) +float(0) diff --git a/ext/standard/tests/math/atanh_basic.phpt b/ext/standard/tests/math/atanh_basic.phpt new file mode 100644 index 0000000000..c259bdb82b --- /dev/null +++ b/ext/standard/tests/math/atanh_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test return type and value for expected input atanh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float atanh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "atanh 0.46211715726001 = "; +var_dump(atanh(0.46211715726001)); +if (allowed_rounding_error(atanh(0.46211715726001), 0.5)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "atanh 0.99505475368673 = "; +var_dump(atanh(0.99505475368673)); +if (allowed_rounding_error(atanh(0.99505475368673), 3.0)) +{ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + + +?> +--EXPECTF-- +atanh 0.46211715726001 = float(%f) +Pass +atanh 0.99505475368673 = float(%f) +Pass diff --git a/ext/standard/tests/math/atanh_error.phpt b/ext/standard/tests/math/atanh_error.phpt new file mode 100644 index 0000000000..9759610b44 --- /dev/null +++ b/ext/standard/tests/math/atanh_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test wrong number of arguments for atanh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +--FILE-- +<?php +/* + * proto float atanh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(atanh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(atanh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: atanh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: atanh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/atanh_variation.phpt b/ext/standard/tests/math/atanh_variation.phpt new file mode 100644 index 0000000000..acde006980 --- /dev/null +++ b/ext/standard/tests/math/atanh_variation.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test variations in usage of atanh() +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN" ) + die ("skip - function not supported on Windows"); +?> +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float atanh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test atanh 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 = atanh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: atanh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(0) +float(INF) +float(0) +--UEXPECTF-- +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) +float(NAN) + +Warning: atanh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(NAN) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(NAN) +float(0) +float(INF) +float(0) diff --git a/ext/standard/tests/math/cos_basic.phpt b/ext/standard/tests/math/cos_basic.phpt new file mode 100644 index 0000000000..f0cfa66ee5 --- /dev/null +++ b/ext/standard/tests/math/cos_basic.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test return type and value for expected input cos() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float cos(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + + +// Use known values to test + +$sixty = M_PI / 3.0; +$thirty = M_PI / 6.0; +$ninety = M_PI /2.0; +$oneeighty = M_PI; +$twoseventy = M_PI * 1.5; +$threesixty = M_PI * 2.0; + + +echo "cos 30 = "; +var_dump(cos($thirty)); +if (allowed_rounding_error(cos($thirty),0.86602540378444)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cos 60 = "; +var_dump(cos($sixty)); +if (allowed_rounding_error(cos($sixty),0.5)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cos 90 = "; +var_dump(cos($ninety)); +if (allowed_rounding_error(cos($ninety),0.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cos 180 = "; +var_dump(cos($oneeighty)); +if (allowed_rounding_error(cos($oneeighty),-1.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cos 270 = "; +var_dump(cos($twoseventy)); +if (allowed_rounding_error(cos($twoseventy),0.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cos 360 = "; +var_dump(cos($threesixty)); +if (allowed_rounding_error(cos($threesixty),1.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} +?> +--EXPECTF-- +cos 30 = float(%f) +Pass +cos 60 = float(%f) +Pass +cos 90 = float(%f) +Pass +cos 180 = float(%f) +Pass +cos 270 = float(%f) +Pass +cos 360 = float(%f) +Pass diff --git a/ext/standard/tests/math/cos_error.phpt b/ext/standard/tests/math/cos_error.phpt new file mode 100644 index 0000000000..ddd6c876cf --- /dev/null +++ b/ext/standard/tests/math/cos_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for cos() +--INI-- +--FILE-- +<?php +/* + * proto float cos(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(cos($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(cos()); + +?> +--EXPECTF-- +Too many arguments + +Warning: cos() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: cos() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/cos_variation.phpt b/ext/standard/tests/math/cos_variation.phpt new file mode 100644 index 0000000000..9a2327323d --- /dev/null +++ b/ext/standard/tests/math/cos_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of cos() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float cos(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test cos 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 = cos($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(-0.5328330203) +float(-0.5328330203) +float(-0.1117112391) +float(-0.1117112391) +float(-0.5328330203) +float(-0.5328330203) +float(-0.5328330203) +float(-0.1117112391) +float(-0.1117112391) + +Warning: cos() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(0.5623790763) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(0.5623790763) +float(1) +float(0.5403023059) +float(1) +--UEXPECTF-- +float(-0.5328330203) +float(-0.5328330203) +float(-0.1117112391) +float(-0.1117112391) +float(-0.5328330203) +float(-0.5328330203) +float(-0.5328330203) +float(-0.1117112391) +float(-0.1117112391) + +Warning: cos() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(0.5623790763) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(0.5623790763) +float(1) +float(0.5403023059) +float(1) diff --git a/ext/standard/tests/math/cosh_basic.phpt b/ext/standard/tests/math/cosh_basic.phpt new file mode 100644 index 0000000000..5f70334a07 --- /dev/null +++ b/ext/standard/tests/math/cosh_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test return type and value for expected input cosh() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float cosh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "cosh .5 = "; +var_dump(cosh(0.5)); +if (allowed_rounding_error(cosh(0.5),1.1276259652064)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cosh -0.5 = "; +var_dump(cosh(-0.5)); +if (allowed_rounding_error(cosh(-0.5),1.1276259652064)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cosh 3 = "; +var_dump(cosh(3.0)); +if (allowed_rounding_error(cosh(3.0), 10.067661995778)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "cosh -3 = "; +var_dump(cosh(-3.0)); +if (allowed_rounding_error(cosh(-3.0), 10.067661995778)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +cosh .5 = float(%f) +Pass +cosh -0.5 = float(%f) +Pass +cosh 3 = float(%f) +Pass +cosh -3 = float(%f) +Pass diff --git a/ext/standard/tests/math/cosh_error.phpt b/ext/standard/tests/math/cosh_error.phpt new file mode 100644 index 0000000000..7246ed4a9a --- /dev/null +++ b/ext/standard/tests/math/cosh_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for cosh() +--INI-- +--FILE-- +<?php +/* + * proto float cosh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(cosh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(cosh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: cosh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: cosh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/cosh_variation.phpt b/ext/standard/tests/math/cosh_variation.phpt new file mode 100644 index 0000000000..a98aceb5cc --- /dev/null +++ b/ext/standard/tests/math/cosh_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of cosh() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float cosh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test cosh 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 = cosh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) +float(4872401723) +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) + +Warning: cosh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(INF) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(INF) +float(1) +float(1.543080635) +float(1) +--UEXPECTF-- +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) +float(4872401723) +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) + +Warning: cosh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(INF) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(INF) +float(1) +float(1.543080635) +float(1) diff --git a/ext/standard/tests/math/sin_basic.phpt b/ext/standard/tests/math/sin_basic.phpt new file mode 100644 index 0000000000..2b55ad7355 --- /dev/null +++ b/ext/standard/tests/math/sin_basic.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test return type and value for expected input sin() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float sin(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + + +// Use known values to test + +$sixty = M_PI / 3.0; +$thirty = M_PI / 6.0; +$ninety = M_PI /2.0; +$oneeighty = M_PI; +$twoseventy = M_PI * 1.5; +$threesixty = M_PI * 2.0; + + +echo "sin 30 = "; +var_dump(sin($thirty)); +if (allowed_rounding_error(sin($thirty),0.5)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sin 60 = "; +var_dump(sin($sixty)); +if (allowed_rounding_error(sin($sixty),0.86602540378444)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sin 90 = "; +var_dump(sin($ninety)); +if (allowed_rounding_error(sin($ninety),1.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sin 180 = "; +var_dump(sin($oneeighty)); +if (allowed_rounding_error(sin($oneeighty),0.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sin 270 = "; +var_dump(sin($twoseventy)); +if (allowed_rounding_error(sin($twoseventy),-1.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sin 360 = "; +var_dump(sin($threesixty)); +if (allowed_rounding_error(sin($threesixty),0.0)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} +?> +--EXPECTF-- +sin 30 = float(%f) +Pass +sin 60 = float(%f) +Pass +sin 90 = float(%f) +Pass +sin 180 = float(%f) +Pass +sin 270 = float(%f) +Pass +sin 360 = float(%f) +Pass diff --git a/ext/standard/tests/math/sin_error.phpt b/ext/standard/tests/math/sin_error.phpt new file mode 100644 index 0000000000..3dac223f80 --- /dev/null +++ b/ext/standard/tests/math/sin_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for sin() +--INI-- +--FILE-- +<?php +/* + * proto float sin(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(sin($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(sin()); + +?> +--EXPECTF-- +Too many arguments + +Warning: sin() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: sin() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/sin_variation.phpt b/ext/standard/tests/math/sin_variation.phpt new file mode 100644 index 0000000000..32f55caa4f --- /dev/null +++ b/ext/standard/tests/math/sin_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of sin() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float sin(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test sin 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 = sin($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(-0.8462204042) +float(0.8462204042) +float(-0.9937407102) +float(0.9937407102) +float(-0.8462204042) +float(-0.8462204042) +float(-0.8462204042) +float(-0.9937407102) +float(-0.9937407102) + +Warning: sin() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(0.8268795405) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(0.8268795405) +float(0) +float(0.8414709848) +float(0) +--UEXPECTF-- +float(-0.8462204042) +float(0.8462204042) +float(-0.9937407102) +float(0.9937407102) +float(-0.8462204042) +float(-0.8462204042) +float(-0.8462204042) +float(-0.9937407102) +float(-0.9937407102) + +Warning: sin() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(0.8268795405) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(0.8268795405) +float(0) +float(0.8414709848) +float(0) diff --git a/ext/standard/tests/math/sinh_basic.phpt b/ext/standard/tests/math/sinh_basic.phpt new file mode 100644 index 0000000000..79bef6314c --- /dev/null +++ b/ext/standard/tests/math/sinh_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test return type and value for expected input sinh() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float sinh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +echo "sinh .5 = "; +var_dump(sinh(0.5)); +if (allowed_rounding_error(sinh(0.5),0.52109530549375)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sinh -0.5 = "; +var_dump(sinh(-0.5)); +if (allowed_rounding_error(sinh(-0.5), -0.52109530549375)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sinh 3 = "; +var_dump(sinh(3.0)); +if (allowed_rounding_error(sinh(3.0), 10.01787492741)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "sinh -3 = "; +var_dump(sinh(-3.0)); +if (allowed_rounding_error(sinh(-3.0), -10.01787492741)){ + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +sinh .5 = float(%f) +Pass +sinh -0.5 = float(%f) +Pass +sinh 3 = float(%f) +Pass +sinh -3 = float(%f) +Pass diff --git a/ext/standard/tests/math/sinh_error.phpt b/ext/standard/tests/math/sinh_error.phpt new file mode 100644 index 0000000000..5278262616 --- /dev/null +++ b/ext/standard/tests/math/sinh_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for sinh() +--INI-- +--FILE-- +<?php +/* + * proto float sinh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(sinh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(sinh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: sinh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: sinh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/sinh_variation.phpt b/ext/standard/tests/math/sinh_variation.phpt new file mode 100644 index 0000000000..9d495d24b8 --- /dev/null +++ b/ext/standard/tests/math/sinh_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of sinh() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float sinh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test sinh 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 = sinh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(4872401723) +float(-4872401723) +float(7641446995) +float(-7641446995) +float(4872401723) +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) + +Warning: sinh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(INF) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(INF) +float(0) +float(1.175201194) +float(0) +--UEXPECTF-- +float(4872401723) +float(-4872401723) +float(7641446995) +float(-7641446995) +float(4872401723) +float(4872401723) +float(4872401723) +float(7641446995) +float(7641446995) + +Warning: sinh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(INF) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(INF) +float(0) +float(1.175201194) +float(0) diff --git a/ext/standard/tests/math/tan_basic.phpt b/ext/standard/tests/math/tan_basic.phpt new file mode 100644 index 0000000000..e2934fb388 --- /dev/null +++ b/ext/standard/tests/math/tan_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test return type and value for expected input tan() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float tan(float number) + * Function is implemented in ext/standard/math.c +*/ + +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + +$sixty = M_PI / 3.0; +$thirty = M_PI / 6.0; + +echo "tan 60 = "; +var_dump(tan($sixty)); +if (allowed_rounding_error(tan($sixty),1.7320508075689)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "tan 30 = "; +var_dump(tan($thirty)); +if (allowed_rounding_error(tan($thirty),0.57735026918963)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +tan 60 = float(%f) +Pass +tan 30 = float(%f) +Pass diff --git a/ext/standard/tests/math/tan_error.phpt b/ext/standard/tests/math/tan_error.phpt new file mode 100644 index 0000000000..afc76a2be2 --- /dev/null +++ b/ext/standard/tests/math/tan_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for tan() +--INI-- +--FILE-- +<?php +/* + * proto float tan(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(tan($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(tan()); + +?> +--EXPECTF-- +Too many arguments + +Warning: tan() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: tan() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/tan_variation.phpt b/ext/standard/tests/math/tan_variation.phpt new file mode 100644 index 0000000000..a15bf74ddb --- /dev/null +++ b/ext/standard/tests/math/tan_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of tan() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float tan(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test tan 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 = tan($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(1.588153083) +float(-1.588153083) +float(8.895619796) +float(-8.895619796) +float(1.588153083) +float(1.588153083) +float(1.588153083) +float(8.895619796) +float(8.895619796) + +Warning: tan() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(1.470324156) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1.470324156) +float(0) +float(1.557407725) +float(0) +--UEXPECTF-- +float(1.588153083) +float(-1.588153083) +float(8.895619796) +float(-8.895619796) +float(1.588153083) +float(1.588153083) +float(1.588153083) +float(8.895619796) +float(8.895619796) + +Warning: tan() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(1.470324156) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1.470324156) +float(0) +float(1.557407725) +float(0) diff --git a/ext/standard/tests/math/tanh_basic.phpt b/ext/standard/tests/math/tanh_basic.phpt new file mode 100644 index 0000000000..6b6a9dff7d --- /dev/null +++ b/ext/standard/tests/math/tanh_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test return type and value for expected input tanh() +--INI-- +precision = 14 +--FILE-- +<?php +/* + * proto float tanh(float number) + * Function is implemented in ext/standard/math.c +*/ +$file_path = dirname(__FILE__); +require($file_path."/allowed_rounding_error.inc"); + + +echo "tanh .5 = "; +var_dump(tanh(0.5)); +if (allowed_rounding_error(tanh(0.5), 0.46211715726001)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "tanh -0.5 = "; +var_dump(tanh(-0.5)); +if (allowed_rounding_error(tanh(-0.5), -0.46211715726001)) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "tanh 3 = "; +var_dump(tanh(3.0)); +if (allowed_rounding_error(tanh(3.0),0.99505475368673 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +echo "tanh -3 = "; +var_dump(tanh(-3.0)); +if (allowed_rounding_error(tanh(-3.0),-0.99505475368673 )) { + echo "Pass\n"; +} +else { + echo "Fail\n"; +} + +?> +--EXPECTF-- +tanh .5 = float(%f) +Pass +tanh -0.5 = float(%f) +Pass +tanh 3 = float(%f) +Pass +tanh -3 = float(%f) +Pass diff --git a/ext/standard/tests/math/tanh_error.phpt b/ext/standard/tests/math/tanh_error.phpt new file mode 100644 index 0000000000..c72e9a8dca --- /dev/null +++ b/ext/standard/tests/math/tanh_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test wrong number of arguments for tanh() +--INI-- +--FILE-- +<?php +/* + * proto float tanh(float number) + * Function is implemented in ext/standard/math.c +*/ + +$arg_0 = 1.0; +$extra_arg = 1; + +echo "\nToo many arguments\n"; +var_dump(tanh($arg_0, $extra_arg)); + +echo "\nToo few arguments\n"; +var_dump(tanh()); + +?> +--EXPECTF-- +Too many arguments + +Warning: tanh() expects exactly 1 parameter, 2 given in %s on line 11 +NULL + +Too few arguments + +Warning: tanh() expects exactly 1 parameter, 0 given in %s on line 14 +NULL diff --git a/ext/standard/tests/math/tanh_variation.phpt b/ext/standard/tests/math/tanh_variation.phpt new file mode 100644 index 0000000000..9eb21102fb --- /dev/null +++ b/ext/standard/tests/math/tanh_variation.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test variations in usage of tanh() +--INI-- +precision = 10 +--FILE-- +<?php +/* + * proto float tanh(float number) + * Function is implemented in ext/standard/math.c +*/ + + +//Test tanh 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 = tanh($values[$i]); + var_dump($res); +} + +?> +--EXPECTF-- +float(1) +float(-1) +float(1) +float(-1) +float(1) +float(1) +float(1) +float(1) +float(1) + +Warning: tanh() expects parameter 1 to be double, string given in %s on line 27 +NULL +float(1) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1) +float(0) +float(0.761594156) +float(0) +--UEXPECTF-- +float(1) +float(-1) +float(1) +float(-1) +float(1) +float(1) +float(1) +float(1) +float(1) + +Warning: tanh() expects parameter 1 to be double, Unicode string given in %s on line 27 +NULL +float(1) + +Notice: A non well formed numeric value encountered in %s on line 27 +float(1) +float(0) +float(0.761594156) +float(0) |