]> granicus.if.org Git - php/commitdiff
New math tests. Tested on Windows, Linux and Linux 64 bit
authorandy wharmby <wharmby@php.net>
Mon, 12 Jan 2009 14:30:52 +0000 (14:30 +0000)
committerandy wharmby <wharmby@php.net>
Mon, 12 Jan 2009 14:30:52 +0000 (14:30 +0000)
19 files changed:
ext/standard/tests/math/expm1_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/expm1_error.phpt [new file with mode: 0644]
ext/standard/tests/math/expm1_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/floor_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/floor_error.phpt [new file with mode: 0644]
ext/standard/tests/math/floor_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/fmod_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/fmod_variation2.phpt [new file with mode: 0644]
ext/standard/tests/math/hexdec_basic_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/hexdec_error.phpt
ext/standard/tests/math/hexdec_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/hexdec_variation1_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/hypot_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/hypot_error.phpt
ext/standard/tests/math/hypot_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/hypot_variation2.phpt [new file with mode: 0644]
ext/standard/tests/math/is_finite_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/is_infinite_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/is_nan_variation1.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/math/expm1_basic.phpt b/ext/standard/tests/math/expm1_basic.phpt
new file mode 100644 (file)
index 0000000..fa1d571
--- /dev/null
@@ -0,0 +1,79 @@
+--TEST--
+Test expm1() - basic function test for expm1()
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype  : float expm1 ( float $arg  )
+ * Description: Returns exp(number) - 1, computed in a way that is accurate even 
+ *              when the value of number is close to zero.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing expm1() : basic functionality ***\n";
+$values = array(10,
+                               10.3,
+                               3.9505e3,
+                               037,
+                               0x5F,   
+                               "10",
+                               "3950.5",
+                               "3.9505e3",
+                               "039",
+                               "0x5F",
+                               true,
+                               false,
+                               null, 
+                               );      
+
+// loop through each element of $values to check the behaviour of expm1()
+$iterator = 1;
+foreach($values as $value) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(expm1($value));
+       $iterator++;
+};
+?>
+===Done===
+--EXPECTF--
+*** Testing expm1() : basic functionality ***
+
+-- Iteration 1 --
+float(22025.465794807)
+
+-- Iteration 2 --
+float(29731.618852891)
+
+-- Iteration 3 --
+float(INF)
+
+-- Iteration 4 --
+float(29048849665246)
+
+-- Iteration 5 --
+float(1.811239082889E+41)
+
+-- Iteration 6 --
+float(22025.465794807)
+
+-- Iteration 7 --
+float(INF)
+
+-- Iteration 8 --
+float(INF)
+
+-- Iteration 9 --
+float(8.6593400423994E+16)
+
+-- Iteration 10 --
+float(1.811239082889E+41)
+
+-- Iteration 11 --
+float(1.718281828459)
+
+-- Iteration 12 --
+float(0)
+
+-- Iteration 13 --
+float(0)
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/expm1_error.phpt b/ext/standard/tests/math/expm1_error.phpt
new file mode 100644 (file)
index 0000000..380633b
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Test expm1() - Error conditions
+--FILE--
+<?php
+/* Prototype  : float expm1  ( float $arg  )
+ * Description: Returns exp(number) - 1, computed in a way that is accurate even 
+ *              when the value of number is close to zero.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing expm1() : error conditions ***\n";
+
+echo "\n-- Testing expm1() function with less than expected no. of arguments --\n";
+expm1();
+echo "\n-- Testing expm1() function with more than expected no. of arguments --\n";
+expm1(23,true);
+
+?>
+===Done===
+--EXPECTF--
+*** Testing expm1() : error conditions ***
+
+-- Testing expm1() function with less than expected no. of arguments --
+
+Warning: expm1() expects exactly 1 parameter, 0 given in %s on line %d
+
+-- Testing expm1() function with more than expected no. of arguments --
+
+Warning: expm1() expects exactly 1 parameter, 2 given in %s on line %d
+===Done===
diff --git a/ext/standard/tests/math/expm1_variation1.phpt b/ext/standard/tests/math/expm1_variation1.phpt
new file mode 100644 (file)
index 0000000..e976b5a
--- /dev/null
@@ -0,0 +1,199 @@
+--TEST--
+Test expm1() function : usage variations - different data types as $arg argument
+--INI--
+precision=14
+--FILE--
+<?php
+
+/* Prototype  : float expm1  ( float $arg  )
+ * Description: Returns exp(number) - 1, computed in a way that is accurate even 
+ *              when the value of number is close to zero.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing expm1() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $arg argument
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789E4,
+       12.3456789E-4,
+       .5,
+
+       // null data
+/*10*/ NULL,
+       null,
+
+       // boolean data
+/*12*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*16*/ "",
+       '',
+       array(),
+
+       // string data
+/*19*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // array data
+       array(),
+       array(1,2,4),
+       
+       // object data
+/*24*/ new classA(),       
+       
+       // undefined data
+/*25*/ @$undefined_var,
+
+       // unset data
+/*26*/ @$unset_var,
+
+       // resource variable
+/*27*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of expm1()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(expm1($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing expm1() : usage variations ***
+
+-- Iteration 1 --
+float(0)
+
+-- Iteration 2 --
+float(1.718281828459)
+
+-- Iteration 3 --
+float(INF)
+
+-- Iteration 4 --
+float(-1)
+
+-- Iteration 5 --
+float(36314.502674247)
+
+-- Iteration 6 --
+float(-0.99997246355065)
+
+-- Iteration 7 --
+float(INF)
+
+-- Iteration 8 --
+float(0.0012353302826471)
+
+-- Iteration 9 --
+float(0.64872127070013)
+
+-- Iteration 10 --
+float(0)
+
+-- Iteration 11 --
+float(0)
+
+-- Iteration 12 --
+float(1.718281828459)
+
+-- Iteration 13 --
+float(0)
+
+-- Iteration 14 --
+float(1.718281828459)
+
+-- Iteration 15 --
+float(0)
+
+-- Iteration 16 --
+
+Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: expm1() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: expm1() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: expm1() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 25 --
+float(0)
+
+-- Iteration 26 --
+float(0)
+
+-- Iteration 27 --
+
+Warning: expm1() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/floor_basic.phpt b/ext/standard/tests/math/floor_basic.phpt
new file mode 100644 (file)
index 0000000..bbb8a2a
--- /dev/null
@@ -0,0 +1,108 @@
+--TEST--
+Test floor() - basic function test for floor()
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype  : float floor  ( float $value  )
+ * Description: Round fractions down.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing floor() : basic functionality ***\n";
+$values = array(0,
+                               -0,
+                               0.5,
+                               -0.5,
+                               1,
+                               -1,
+                               1.5,
+                               -1.5,
+                               2.6,
+                               -2.6,
+                               037,
+                               0x5F,   
+                               "10.5",
+                               "-10.5",
+                               "3.95E3",
+                               "-3.95E3",
+                               "039",
+                               "0x5F",
+                               true,
+                               false,
+                               null, 
+                               );      
+                               
+foreach($values as $value) {
+       echo "\n-- floor $value --\n";
+       var_dump(floor($value));
+};                             
+
+?>
+===Done===
+--EXPECTF--
+*** Testing floor() : basic functionality ***
+
+-- floor 0 --
+float(0)
+
+-- floor 0 --
+float(0)
+
+-- floor 0.5 --
+float(0)
+
+-- floor -0.5 --
+float(-1)
+
+-- floor 1 --
+float(1)
+
+-- floor -1 --
+float(-1)
+
+-- floor 1.5 --
+float(1)
+
+-- floor -1.5 --
+float(-2)
+
+-- floor 2.6 --
+float(2)
+
+-- floor -2.6 --
+float(-3)
+
+-- floor 31 --
+float(31)
+
+-- floor 95 --
+float(95)
+
+-- floor 10.5 --
+float(10)
+
+-- floor -10.5 --
+float(-11)
+
+-- floor 3.95E3 --
+float(3950)
+
+-- floor -3.95E3 --
+float(-3950)
+
+-- floor 039 --
+float(39)
+
+-- floor 0x5F --
+float(95)
+
+-- floor 1 --
+float(1)
+
+-- floor  --
+float(0)
+
+-- floor  --
+float(0)
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/floor_error.phpt b/ext/standard/tests/math/floor_error.phpt
new file mode 100644 (file)
index 0000000..f33902e
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+Test floor() - error conditions - incorrect number of args
+--FILE--
+<?php
+/* Prototype  : float floor  ( float $value  )
+ * Description: Round fractions down.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing floor() :  error conditions ***\n";
+$arg_0 = 1.0;
+$extra_arg = 1;
+
+echo "\n-- Too many arguments --\n";
+var_dump(floor($arg_0, $extra_arg));
+
+echo "\n-- Too few arguments --\n";
+var_dump(floor());
+?>
+===Done===
+--EXPECTF--
+*** Testing floor() :  error conditions ***
+
+-- Too many arguments --
+
+Warning: floor() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+-- Too few arguments --
+
+Warning: floor() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/floor_variation1.phpt b/ext/standard/tests/math/floor_variation1.phpt
new file mode 100644 (file)
index 0000000..baba53a
--- /dev/null
@@ -0,0 +1,128 @@
+--TEST--
+Test floor() function : usage variations - different data types as $value arg
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype  : float floor  ( float $value  )
+ * Description: Round fractions down.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing floor() : usage variations ***\n";
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $value argument
+$inputs = array(
+       // null data
+/* 1*/ NULL,
+       null,
+
+       // boolean data
+/* 3*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/* 7*/ "",
+       '',
+       array(),
+
+       // string data
+/*10*/ "abcxyz",
+       'abcxyz}',
+       $heredoc,
+       
+       // object data
+/*13*/ new classA(),
+
+       // undefined data
+/*14*/ @$undefined_var,
+
+       // unset data
+/*15*/ @$unset_var,
+
+       // resource variable
+/*16*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of floor()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(floor($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing floor() : usage variations ***
+
+-- Iteration 1 --
+float(0)
+
+-- Iteration 2 --
+float(0)
+
+-- Iteration 3 --
+float(1)
+
+-- Iteration 4 --
+float(0)
+
+-- Iteration 5 --
+float(1)
+
+-- Iteration 6 --
+float(0)
+
+-- Iteration 7 --
+float(0)
+
+-- Iteration 8 --
+float(0)
+
+-- Iteration 9 --
+bool(false)
+
+-- Iteration 10 --
+float(0)
+
+-- Iteration 11 --
+float(0)
+
+-- Iteration 12 --
+float(0)
+
+-- Iteration 13 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+float(1)
+
+-- Iteration 14 --
+float(0)
+
+-- Iteration 15 --
+float(0)
+
+-- Iteration 16 --
+float(%f)
+===Done===
diff --git a/ext/standard/tests/math/fmod_variation1.phpt b/ext/standard/tests/math/fmod_variation1.phpt
new file mode 100644 (file)
index 0000000..9c6ab13
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test fmod() function : usage variations - different data types as $x argument
+--FILE--
+<?php
+/* Prototype  : float fmod  ( float $x  , float $y  )
+ * Description: Returns the floating point remainder (modulo) of the division of the arguments.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing fmod() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of fmod()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(fmod($input, 2));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing fmod() : usage variations ***
+
+-- Iteration 1 --
+float(0)
+
+-- Iteration 2 --
+float(1)
+
+-- Iteration 3 --
+float(1)
+
+-- Iteration 4 --
+float(-1)
+
+-- Iteration 5 --
+float(1)
+
+-- Iteration 6 --
+float(0.5)
+
+-- Iteration 7 --
+float(-0.5)
+
+-- Iteration 8 --
+float(0)
+
+-- Iteration 9 --
+float(1.23456789E-9)
+
+-- Iteration 10 --
+float(0.5)
+
+-- Iteration 11 --
+float(0)
+
+-- Iteration 12 --
+float(0)
+
+-- Iteration 13 --
+float(1)
+
+-- Iteration 14 --
+float(0)
+
+-- Iteration 15 --
+float(1)
+
+-- Iteration 16 --
+float(0)
+
+-- Iteration 17 --
+
+Warning: fmod() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: fmod() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: fmod() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: fmod() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: fmod() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: fmod() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: fmod() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(0)
+
+-- Iteration 25 --
+float(0)
+
+-- Iteration 26 --
+
+Warning: fmod() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/fmod_variation2.phpt b/ext/standard/tests/math/fmod_variation2.phpt
new file mode 100644 (file)
index 0000000..bbeddb6
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test fmod() function : usage variations - different data types as $y argument
+--FILE--
+<?php
+/* Prototype  : float fmod  ( float $x  , float $y  )
+ * Description: Returns the floating point remainder (modulo) of the division of the arguments.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing fmod() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of fmod()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(fmod(123456, $input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing fmod() : usage variations ***
+
+-- Iteration 1 --
+float(NAN)
+
+-- Iteration 2 --
+float(0)
+
+-- Iteration 3 --
+float(6)
+
+-- Iteration 4 --
+float(1516)
+
+-- Iteration 5 --
+float(123456)
+
+-- Iteration 6 --
+float(7.5)
+
+-- Iteration 7 --
+float(7.5)
+
+-- Iteration 8 --
+float(123456)
+
+-- Iteration 9 --
+float(2.3605615109341E-10)
+
+-- Iteration 10 --
+float(0)
+
+-- Iteration 11 --
+float(NAN)
+
+-- Iteration 12 --
+float(NAN)
+
+-- Iteration 13 --
+float(0)
+
+-- Iteration 14 --
+float(NAN)
+
+-- Iteration 15 --
+float(0)
+
+-- Iteration 16 --
+float(NAN)
+
+-- Iteration 17 --
+
+Warning: fmod() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: fmod() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: fmod() expects parameter 2 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: fmod() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: fmod() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: fmod() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: fmod() expects parameter 2 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(NAN)
+
+-- Iteration 25 --
+float(NAN)
+
+-- Iteration 26 --
+
+Warning: fmod() expects parameter 2 to be double, resource given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/hexdec_basic_64bit.phpt b/ext/standard/tests/math/hexdec_basic_64bit.phpt
new file mode 100644 (file)
index 0000000..f1a2028
--- /dev/null
@@ -0,0 +1,93 @@
+--TEST--
+Test hexdec() - basic function test hexdec()
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+echo "*** Testing hexdec() : basic functionality ***\n";
+
+$values = array(0x123abc,
+                               0x789DEF,
+                               0x7FFFFFFF,
+                               0x80000000,
+                               '0x123abc',
+                               '0x789DEF',
+                               '0x7FFFFFFF',
+                               '0x80000000',
+                               '0x123XYZABC',
+                               311015,
+                               '311015',
+                               31101.3,
+                               31.1013e5,
+                               011237, 
+                               '011237',                       
+                               true,
+                               false,
+                               null);  
+
+foreach($values as $value) {
+       echo "\n-- hexdec $value --\n";
+       var_dump(hexdec($value));
+};                                             
+                               
+?>
+===Done===
+--EXPECTF--
+*** Testing hexdec() : basic functionality ***
+
+-- hexdec 1194684 --
+int(18433668)
+
+-- hexdec 7904751 --
+int(126895953)
+
+-- hexdec 2147483647 --
+int(142929835591)
+
+-- hexdec 2147483648 --
+int(142929835592)
+
+-- hexdec 0x123abc --
+int(1194684)
+
+-- hexdec 0x789DEF --
+int(7904751)
+
+-- hexdec 0x7FFFFFFF --
+int(2147483647)
+
+-- hexdec 0x80000000 --
+int(2147483648)
+
+-- hexdec 0x123XYZABC --
+int(1194684)
+
+-- hexdec 311015 --
+int(3215381)
+
+-- hexdec 311015 --
+int(3215381)
+
+-- hexdec 31101.3 --
+int(3215379)
+
+-- hexdec 3110130 --
+int(51446064)
+
+-- hexdec 4767 --
+int(18279)
+
+-- hexdec 011237 --
+int(70199)
+
+-- hexdec 1 --
+int(1)
+
+-- hexdec  --
+int(0)
+
+-- hexdec  --
+int(0)
+===Done===
\ No newline at end of file
index dae83b8564c334de78ef4badabfafbfc8fe4b54a..e9ab9e512de5f9f94f64a55b4dd4324e41db2a52 100644 (file)
@@ -2,10 +2,35 @@
 Test hexdec() - wrong params test hexdec()
 --FILE--
 <?php
+/* Prototype  : number hexdec  ( string $hex_string  )
+ * Description: Returns the decimal equivalent of the hexadecimal number represented by the hex_string  argument. 
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hexdec() :  error conditions ***\n";
+
+// get a class
+class classA
+{
+}
+
+echo "\n-- Incorrect number of arguments --\n";
 hexdec();
 hexdec('0x123abc',true);
+
+echo "\n-- Incorrect input --\n";
+hexdec(new classA());
+
 ?>
 --EXPECTF--
+*** Testing hexdec() :  error conditions ***
+
+-- Incorrect number of arguments --
+
 Warning: hexdec() expects exactly 1 parameter, 0 given in %s on line %d
 
 Warning: hexdec() expects exactly 1 parameter, 2 given in %s on line %d
+
+-- Incorrect input --
+
+Catchable fatal error: Object of class classA could not be converted to string in %s on line %d
\ No newline at end of file
diff --git a/ext/standard/tests/math/hexdec_variation1.phpt b/ext/standard/tests/math/hexdec_variation1.phpt
new file mode 100644 (file)
index 0000000..2b3f1b6
--- /dev/null
@@ -0,0 +1,168 @@
+--TEST--
+Test hexdec() function : usage variations - different data types as $number arg
+--INI--
+precision=14
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : number hexdec  ( string $hex_string  )
+ * Description: Returns the decimal equivalent of the hexadecimal number represented by the hex_string  argument. 
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hexdec() : usage variations ***\n";
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       4294967295,  // largest decimal  
+       4294967296, 
+
+       // float data
+/*7*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*12*/ NULL,
+       null,
+
+       // boolean data
+/*14*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*18*/ "",
+       '',
+       array(),
+
+       // string data
+/*21*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of hexdec()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(hexdec($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing hexdec() : usage variations ***
+
+-- Iteration 1 --
+int(0)
+
+-- Iteration 2 --
+int(1)
+
+-- Iteration 3 --
+int(74565)
+
+-- Iteration 4 --
+int(9029)
+
+-- Iteration 5 --
+float(285960729237)
+
+-- Iteration 6 --
+float(285960729238)
+
+-- Iteration 7 --
+int(261)
+
+-- Iteration 8 --
+int(261)
+
+-- Iteration 9 --
+float(20015998341120)
+
+-- Iteration 10 --
+float(1250999896553)
+
+-- Iteration 11 --
+int(5)
+
+-- Iteration 12 --
+int(0)
+
+-- Iteration 13 --
+int(0)
+
+-- Iteration 14 --
+int(1)
+
+-- Iteration 15 --
+int(0)
+
+-- Iteration 16 --
+int(1)
+
+-- Iteration 17 --
+int(0)
+
+-- Iteration 18 --
+int(0)
+
+-- Iteration 19 --
+int(0)
+
+-- Iteration 20 --
+
+Notice: Array to string conversion in %s on line %d
+int(170)
+
+-- Iteration 21 --
+int(2748)
+
+-- Iteration 22 --
+int(2748)
+
+-- Iteration 23 --
+int(2748)
+
+-- Iteration 24 --
+int(0)
+
+-- Iteration 25 --
+int(0)
+
+-- Iteration 26 --
+%s
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/hexdec_variation1_64bit.phpt b/ext/standard/tests/math/hexdec_variation1_64bit.phpt
new file mode 100644 (file)
index 0000000..65beb2d
--- /dev/null
@@ -0,0 +1,168 @@
+--TEST--
+Test hexdec() function : usage variations - different data types as $number arg
+--INI--
+precision=14
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : number hexdec  ( string $hex_string  )
+ * Description: Returns the decimal equivalent of the hexadecimal number represented by the hex_string  argument. 
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hexdec() : usage variations ***\n";
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       4294967295,  // largest decimal  
+       4294967296, 
+
+       // float data
+/*7*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*12*/ NULL,
+       null,
+
+       // boolean data
+/*14*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*18*/ "",
+       '',
+       array(),
+
+       // string data
+/*21*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of hexdec()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(hexdec($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing hexdec() : usage variations ***
+
+-- Iteration 1 --
+int(0)
+
+-- Iteration 2 --
+int(1)
+
+-- Iteration 3 --
+int(74565)
+
+-- Iteration 4 --
+int(9029)
+
+-- Iteration 5 --
+int(285960729237)
+
+-- Iteration 6 --
+int(285960729238)
+
+-- Iteration 7 --
+int(261)
+
+-- Iteration 8 --
+int(261)
+
+-- Iteration 9 --
+int(20015998341120)
+
+-- Iteration 10 --
+int(1250999896553)
+
+-- Iteration 11 --
+int(5)
+
+-- Iteration 12 --
+int(0)
+
+-- Iteration 13 --
+int(0)
+
+-- Iteration 14 --
+int(1)
+
+-- Iteration 15 --
+int(0)
+
+-- Iteration 16 --
+int(1)
+
+-- Iteration 17 --
+int(0)
+
+-- Iteration 18 --
+int(0)
+
+-- Iteration 19 --
+int(0)
+
+-- Iteration 20 --
+
+Notice: Array to string conversion in %s on line %d
+int(170)
+
+-- Iteration 21 --
+int(2748)
+
+-- Iteration 22 --
+int(2748)
+
+-- Iteration 23 --
+int(2748)
+
+-- Iteration 24 --
+int(0)
+
+-- Iteration 25 --
+int(0)
+
+-- Iteration 26 --
+%s
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/hypot_basic.phpt b/ext/standard/tests/math/hypot_basic.phpt
new file mode 100644 (file)
index 0000000..c280a23
--- /dev/null
@@ -0,0 +1,444 @@
+--TEST--
+Test hypot() - basic function test hypot()
+--INI--
+precision=14
+--FILE--
+<?php
+
+/* Prototype  : float hypot  ( float $x  , float $y  )
+ * Description: Calculate the length of the hypotenuse of a right-angle triangle.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hypot() : basic functionality ***\n";
+
+$valuesy = array(23,
+                               -23,
+                               2.345e1,
+                               -2.345e1,
+                               0x17,
+                               027,
+                               "23",
+                               "23.45",
+                               "2.345e1",      
+                               "23abc",                        
+                               null,
+                               true,
+                               false);
+                                       
+$valuesx = array(33,
+                               -33,
+                               3.345e1,
+                               -3.345e1,
+                               0x27,
+                               037,
+                               "33",
+                               "43.45",
+                               "1.345e1",
+                               "33abc",                                
+                               null,
+                               true,
+                               false);                                 
+
+for ($i = 0; $i < count($valuesy); $i++) {
+       for ($j = 0; $j < count($valuesx); $j++) {      
+               echo "\nY:$valuesy[$i] X:$valuesx[$j] ";
+               $res = hypot($valuesy[$i], $valuesx[$j]);
+               var_dump($res);
+       }       
+}
+?>
+===Done===
+--EXPECTF--
+*** Testing hypot() : basic functionality ***
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:-33 float(40.224370722238)
+
+Y:23 X:33.45 float(40.594365372549)
+
+Y:23 X:-33.45 float(40.594365372549)
+
+Y:23 X:39 float(45.276925690687)
+
+Y:23 X:31 float(38.600518131238)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:43.45 float(49.162002603637)
+
+Y:23 X:1.345e1 float(26.643995571235)
+
+Y:23 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23 X: float(23)
+
+Y:23 X:1 float(23.021728866443)
+
+Y:23 X: float(23)
+
+Y:-23 X:33 float(40.224370722238)
+
+Y:-23 X:-33 float(40.224370722238)
+
+Y:-23 X:33.45 float(40.594365372549)
+
+Y:-23 X:-33.45 float(40.594365372549)
+
+Y:-23 X:39 float(45.276925690687)
+
+Y:-23 X:31 float(38.600518131238)
+
+Y:-23 X:33 float(40.224370722238)
+
+Y:-23 X:43.45 float(49.162002603637)
+
+Y:-23 X:1.345e1 float(26.643995571235)
+
+Y:-23 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:-23 X: float(23)
+
+Y:-23 X:1 float(23.021728866443)
+
+Y:-23 X: float(23)
+
+Y:23.45 X:33 float(40.483360779461)
+
+Y:23.45 X:-33 float(40.483360779461)
+
+Y:23.45 X:33.45 float(40.851009779441)
+
+Y:23.45 X:-33.45 float(40.851009779441)
+
+Y:23.45 X:39 float(45.507169764774)
+
+Y:23.45 X:31 float(38.870329301409)
+
+Y:23.45 X:33 float(40.483360779461)
+
+Y:23.45 X:43.45 float(49.374132903779)
+
+Y:23.45 X:1.345e1 float(27.033405260899)
+
+Y:23.45 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.483360779461)
+
+Y:23.45 X: float(23.45)
+
+Y:23.45 X:1 float(23.471312276905)
+
+Y:23.45 X: float(23.45)
+
+Y:-23.45 X:33 float(40.483360779461)
+
+Y:-23.45 X:-33 float(40.483360779461)
+
+Y:-23.45 X:33.45 float(40.851009779441)
+
+Y:-23.45 X:-33.45 float(40.851009779441)
+
+Y:-23.45 X:39 float(45.507169764774)
+
+Y:-23.45 X:31 float(38.870329301409)
+
+Y:-23.45 X:33 float(40.483360779461)
+
+Y:-23.45 X:43.45 float(49.374132903779)
+
+Y:-23.45 X:1.345e1 float(27.033405260899)
+
+Y:-23.45 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.483360779461)
+
+Y:-23.45 X: float(23.45)
+
+Y:-23.45 X:1 float(23.471312276905)
+
+Y:-23.45 X: float(23.45)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:-33 float(40.224370722238)
+
+Y:23 X:33.45 float(40.594365372549)
+
+Y:23 X:-33.45 float(40.594365372549)
+
+Y:23 X:39 float(45.276925690687)
+
+Y:23 X:31 float(38.600518131238)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:43.45 float(49.162002603637)
+
+Y:23 X:1.345e1 float(26.643995571235)
+
+Y:23 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23 X: float(23)
+
+Y:23 X:1 float(23.021728866443)
+
+Y:23 X: float(23)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:-33 float(40.224370722238)
+
+Y:23 X:33.45 float(40.594365372549)
+
+Y:23 X:-33.45 float(40.594365372549)
+
+Y:23 X:39 float(45.276925690687)
+
+Y:23 X:31 float(38.600518131238)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:43.45 float(49.162002603637)
+
+Y:23 X:1.345e1 float(26.643995571235)
+
+Y:23 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23 X: float(23)
+
+Y:23 X:1 float(23.021728866443)
+
+Y:23 X: float(23)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:-33 float(40.224370722238)
+
+Y:23 X:33.45 float(40.594365372549)
+
+Y:23 X:-33.45 float(40.594365372549)
+
+Y:23 X:39 float(45.276925690687)
+
+Y:23 X:31 float(38.600518131238)
+
+Y:23 X:33 float(40.224370722238)
+
+Y:23 X:43.45 float(49.162002603637)
+
+Y:23 X:1.345e1 float(26.643995571235)
+
+Y:23 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23 X: float(23)
+
+Y:23 X:1 float(23.021728866443)
+
+Y:23 X: float(23)
+
+Y:23.45 X:33 float(40.483360779461)
+
+Y:23.45 X:-33 float(40.483360779461)
+
+Y:23.45 X:33.45 float(40.851009779441)
+
+Y:23.45 X:-33.45 float(40.851009779441)
+
+Y:23.45 X:39 float(45.507169764774)
+
+Y:23.45 X:31 float(38.870329301409)
+
+Y:23.45 X:33 float(40.483360779461)
+
+Y:23.45 X:43.45 float(49.374132903779)
+
+Y:23.45 X:1.345e1 float(27.033405260899)
+
+Y:23.45 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.483360779461)
+
+Y:23.45 X: float(23.45)
+
+Y:23.45 X:1 float(23.471312276905)
+
+Y:23.45 X: float(23.45)
+
+Y:2.345e1 X:33 float(40.483360779461)
+
+Y:2.345e1 X:-33 float(40.483360779461)
+
+Y:2.345e1 X:33.45 float(40.851009779441)
+
+Y:2.345e1 X:-33.45 float(40.851009779441)
+
+Y:2.345e1 X:39 float(45.507169764774)
+
+Y:2.345e1 X:31 float(38.870329301409)
+
+Y:2.345e1 X:33 float(40.483360779461)
+
+Y:2.345e1 X:43.45 float(49.374132903779)
+
+Y:2.345e1 X:1.345e1 float(27.033405260899)
+
+Y:2.345e1 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.483360779461)
+
+Y:2.345e1 X: float(23.45)
+
+Y:2.345e1 X:1 float(23.471312276905)
+
+Y:2.345e1 X: float(23.45)
+
+Y:23abc X:33 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23abc X:-33 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23abc X:33.45 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.594365372549)
+
+Y:23abc X:-33.45 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.594365372549)
+
+Y:23abc X:39 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(45.276925690687)
+
+Y:23abc X:31 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(38.600518131238)
+
+Y:23abc X:33 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23abc X:43.45 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(49.162002603637)
+
+Y:23abc X:1.345e1 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(26.643995571235)
+
+Y:23abc X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+
+Notice: A non well formed numeric value encountered in %s on line %d
+float(40.224370722238)
+
+Y:23abc X: 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(23)
+
+Y:23abc X:1 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(23.021728866443)
+
+Y:23abc X: 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(23)
+
+Y: X:33 float(33)
+
+Y: X:-33 float(33)
+
+Y: X:33.45 float(33.45)
+
+Y: X:-33.45 float(33.45)
+
+Y: X:39 float(39)
+
+Y: X:31 float(31)
+
+Y: X:33 float(33)
+
+Y: X:43.45 float(43.45)
+
+Y: X:1.345e1 float(13.45)
+
+Y: X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(33)
+
+Y: X: float(0)
+
+Y: X:1 float(1)
+
+Y: X: float(0)
+
+Y:1 X:33 float(33.015148038438)
+
+Y:1 X:-33 float(33.015148038438)
+
+Y:1 X:33.45 float(33.464944344792)
+
+Y:1 X:-33.45 float(33.464944344792)
+
+Y:1 X:39 float(39.012818406262)
+
+Y:1 X:31 float(31.016124838542)
+
+Y:1 X:33 float(33.015148038438)
+
+Y:1 X:43.45 float(43.461505956421)
+
+Y:1 X:1.345e1 float(13.487123488721)
+
+Y:1 X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(33.015148038438)
+
+Y:1 X: float(1)
+
+Y:1 X:1 float(1.4142135623731)
+
+Y:1 X: float(1)
+
+Y: X:33 float(33)
+
+Y: X:-33 float(33)
+
+Y: X:33.45 float(33.45)
+
+Y: X:-33.45 float(33.45)
+
+Y: X:39 float(39)
+
+Y: X:31 float(31)
+
+Y: X:33 float(33)
+
+Y: X:43.45 float(43.45)
+
+Y: X:1.345e1 float(13.45)
+
+Y: X:33abc 
+Notice: A non well formed numeric value encountered in %s on line %d
+float(33)
+
+Y: X: float(0)
+
+Y: X:1 float(1)
+
+Y: X: float(0)
+===Done===
\ No newline at end of file
index 7f3081bc6221392c0089668a2b5d20291e55a545..b357a3a80971e1e42452ff3d7641dfb1ae82fc8d 100644 (file)
@@ -1,16 +1,33 @@
 --TEST--
 Test hypot() - wrong params test hypot()
---INI--
-precision=14
 --FILE--
 <?php
+/* Prototype  : float hypot  ( float $x  , float $y  )
+ * Description: Calculate the length of the hypotenuse of a right-angle triangle.
+ * Source code: ext/standard/math.c
+ */
+echo "*** Testing hypot() : error conditions ***\n";
+
+echo "\n-- Testing hypot() function with less than expected no. of arguments --\n";
 hypot();
 hypot(36);
+
+echo "\n-- Testing hypot() function with more than expected no. of arguments --\n";
 hypot(36,25,0);
+
 ?>
+===Done===
 --EXPECTF--
+*** Testing hypot() : error conditions ***
+
+-- Testing hypot() function with less than expected no. of arguments --
+
 Warning: hypot() expects exactly 2 parameters, 0 given in %s on line %d
 
 Warning: hypot() expects exactly 2 parameters, 1 given in %s on line %d
 
+-- Testing hypot() function with more than expected no. of arguments --
+
 Warning: hypot() expects exactly 2 parameters, 3 given in %s on line %d
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/hypot_variation1.phpt b/ext/standard/tests/math/hypot_variation1.phpt
new file mode 100644 (file)
index 0000000..5ea8b3f
--- /dev/null
@@ -0,0 +1,185 @@
+--TEST--
+Test hypot() function : usage variations - different data types as $x argument
+--FILE--
+<?php
+/* Prototype  : float hypot  ( float $x  , float $y  )
+ * Description: Calculate the length of the hypotenuse of a right-angle triangle
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hypot() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $arg argument
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of hypot()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(hypot($input, 5));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing hypot() : usage variations ***
+
+-- Iteration 1 --
+float(5)
+
+-- Iteration 2 --
+float(5.0990195135928)
+
+-- Iteration 3 --
+float(12345.001012556)
+
+-- Iteration 4 --
+float(2345.0053304843)
+
+-- Iteration 5 --
+float(2147483647)
+
+-- Iteration 6 --
+float(11.629703349613)
+
+-- Iteration 7 --
+float(11.629703349613)
+
+-- Iteration 8 --
+float(123456789000)
+
+-- Iteration 9 --
+float(5)
+
+-- Iteration 10 --
+float(5.0249378105604)
+
+-- Iteration 11 --
+float(5)
+
+-- Iteration 12 --
+float(5)
+
+-- Iteration 13 --
+float(5.0990195135928)
+
+-- Iteration 14 --
+float(5)
+
+-- Iteration 15 --
+float(5.0990195135928)
+
+-- Iteration 16 --
+float(5)
+
+-- Iteration 17 --
+
+Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: hypot() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: hypot() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: hypot() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(5)
+
+-- Iteration 25 --
+float(5)
+
+-- Iteration 26 --
+
+Warning: hypot() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/hypot_variation2.phpt b/ext/standard/tests/math/hypot_variation2.phpt
new file mode 100644 (file)
index 0000000..a629474
--- /dev/null
@@ -0,0 +1,185 @@
+--TEST--
+Test hypot() function : usage variations - different data types as $y argument
+--FILE--
+<?php
+/* Prototype  : float hypot  ( float $x  , float $y  )
+ * Description: Calculate the length of the hypotenuse of a right-angle triangle
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing hypot() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $arg argument
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of hypot()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(hypot(3, $input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing hypot() : usage variations ***
+
+-- Iteration 1 --
+float(3)
+
+-- Iteration 2 --
+float(3.1622776601684)
+
+-- Iteration 3 --
+float(12345.00036452)
+
+-- Iteration 4 --
+float(2345.0019189758)
+
+-- Iteration 5 --
+float(2147483647)
+
+-- Iteration 6 --
+float(10.920164833921)
+
+-- Iteration 7 --
+float(10.920164833921)
+
+-- Iteration 8 --
+float(123456789000)
+
+-- Iteration 9 --
+float(3)
+
+-- Iteration 10 --
+float(3.0413812651491)
+
+-- Iteration 11 --
+float(3)
+
+-- Iteration 12 --
+float(3)
+
+-- Iteration 13 --
+float(3.1622776601684)
+
+-- Iteration 14 --
+float(3)
+
+-- Iteration 15 --
+float(3.1622776601684)
+
+-- Iteration 16 --
+float(3)
+
+-- Iteration 17 --
+
+Warning: hypot() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: hypot() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: hypot() expects parameter 2 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: hypot() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: hypot() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: hypot() expects parameter 2 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: hypot() expects parameter 2 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(3)
+
+-- Iteration 25 --
+float(3)
+
+-- Iteration 26 --
+
+Warning: hypot() expects parameter 2 to be double, resource given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/is_finite_variation1.phpt b/ext/standard/tests/math/is_finite_variation1.phpt
new file mode 100644 (file)
index 0000000..83786ad
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test is_finite() function : usage variations - different data types as $val argument
+--FILE--
+<?php
+/* Prototype  : bool is_finite  ( float $val  )
+ * Description: Finds whether a value is a legal finite number.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing is_finite() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of is_finite()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(is_finite($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing is_finite() : usage variations ***
+
+-- Iteration 1 --
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+
+-- Iteration 5 --
+bool(true)
+
+-- Iteration 6 --
+bool(true)
+
+-- Iteration 7 --
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+
+-- Iteration 11 --
+bool(true)
+
+-- Iteration 12 --
+bool(true)
+
+-- Iteration 13 --
+bool(true)
+
+-- Iteration 14 --
+bool(true)
+
+-- Iteration 15 --
+bool(true)
+
+-- Iteration 16 --
+bool(true)
+
+-- Iteration 17 --
+
+Warning: is_finite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: is_finite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: is_finite() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: is_finite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: is_finite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: is_finite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: is_finite() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+bool(true)
+
+-- Iteration 25 --
+bool(true)
+
+-- Iteration 26 --
+
+Warning: is_finite() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/is_infinite_variation1.phpt b/ext/standard/tests/math/is_infinite_variation1.phpt
new file mode 100644 (file)
index 0000000..0d8573d
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test is_infinite() function : usage variations - different data types as $val argument
+--FILE--
+<?php
+/* Prototype  : bool is_finite  ( float $val  )
+ * Description: Finds whether a value is infinite.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing is_infinite() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of is_infinite()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(is_infinite($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing is_infinite() : usage variations ***
+
+-- Iteration 1 --
+bool(false)
+
+-- Iteration 2 --
+bool(false)
+
+-- Iteration 3 --
+bool(false)
+
+-- Iteration 4 --
+bool(false)
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+
+-- Iteration 8 --
+bool(false)
+
+-- Iteration 9 --
+bool(false)
+
+-- Iteration 10 --
+bool(false)
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+bool(false)
+
+-- Iteration 13 --
+bool(false)
+
+-- Iteration 14 --
+bool(false)
+
+-- Iteration 15 --
+bool(false)
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+
+Warning: is_infinite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: is_infinite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: is_infinite() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: is_infinite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: is_infinite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: is_infinite() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: is_infinite() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+bool(false)
+
+-- Iteration 25 --
+bool(false)
+
+-- Iteration 26 --
+
+Warning: is_infinite() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/is_nan_variation1.phpt b/ext/standard/tests/math/is_nan_variation1.phpt
new file mode 100644 (file)
index 0000000..3eb6429
--- /dev/null
@@ -0,0 +1,184 @@
+--TEST--
+Test is_nan() function : usage variations - different data types as $val argument
+--FILE--
+<?php
+/* Prototype  : bool is_nan  ( float $val  )
+ * Description: Finds whether a value is not a number.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing is_nan() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+// get a class
+class classA
+{
+}
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+$inputs = array(
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,       
+       2147483647,
+
+       // float data
+/*6*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+
+       // null data
+/*11*/ NULL,
+       null,
+
+       // boolean data
+/*13*/ true,
+       false,
+       TRUE,
+       FALSE,
+       
+       // empty data
+/*17*/ "",
+       '',
+       array(),
+
+       // string data
+/*20*/ "abcxyz",
+       'abcxyz',
+       $heredoc,
+       
+       // object data
+/*23*/ new classA(),       
+       
+       // undefined data
+/*24*/ @$undefined_var,
+
+       // unset data
+/*25*/ @$unset_var,
+
+       // resource variable
+/*26*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of is_nan()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(is_nan($input));
+       $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing is_nan() : usage variations ***
+
+-- Iteration 1 --
+bool(false)
+
+-- Iteration 2 --
+bool(false)
+
+-- Iteration 3 --
+bool(false)
+
+-- Iteration 4 --
+bool(false)
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+
+-- Iteration 8 --
+bool(false)
+
+-- Iteration 9 --
+bool(false)
+
+-- Iteration 10 --
+bool(false)
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+bool(false)
+
+-- Iteration 13 --
+bool(false)
+
+-- Iteration 14 --
+bool(false)
+
+-- Iteration 15 --
+bool(false)
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+
+Warning: is_nan() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: is_nan() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: is_nan() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: is_nan() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: is_nan() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: is_nan() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: is_nan() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+bool(false)
+
+-- Iteration 25 --
+bool(false)
+
+-- Iteration 26 --
+
+Warning: is_nan() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===