--- /dev/null
+--TEST--
+Test abs() function : basic functionality
+--INI--
+precision = 14
+--FILE--
+<?php
+/* Prototype : number abs ( mixed $number )
+ * Description: Returns the absolute value of number.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing abs() : basic functionality ***\n";
+
+$values = array(23,
+ -23,
+ 2.345e1,
+ -2.345e1,
+ 0x17,
+ 027,
+ "23",
+ "-23",
+ "23.45",
+ "2.345e1",
+ "-2.345e1",
+ null,
+ true,
+ false);
+
+for ($i = 0; $i < count($values); $i++) {
+ $res = abs($values[$i]);
+ var_dump($res);
+}
+?>
+===Done===
+--EXPECTF--
+*** Testing abs() : basic functionality ***
+int(23)
+int(23)
+float(23.45)
+float(23.45)
+int(23)
+int(23)
+int(23)
+int(23)
+float(23.45)
+float(23.45)
+float(23.45)
+int(0)
+int(1)
+int(0)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test abs() function : error conditions - incorrect number of args
+--FILE--
+<?php
+/* Prototype : number abs ( mixed $number )
+ * Description: Returns the absolute value of number.
+ * Source code: ext/standard/math.c
+ */
+
+/*
+ * Pass incorrect number of arguments to abs() to test behaviour
+ */
+
+echo "*** Testing abs() : error conditions ***\n";
+
+$arg_0 = 1.0;
+$extra_arg = 1;
+
+echo "\nToo many arguments\n";
+var_dump(abs($arg_0, $extra_arg));
+
+echo "\nToo few arguments\n";
+var_dump(abs());
+
+?>
+===Done===
+--EXPECTF--
+*** Testing abs() : error conditions ***
+
+Too many arguments
+
+Warning: Wrong parameter count for abs() in %s on line %d
+NULL
+
+Too few arguments
+
+Warning: Wrong parameter count for abs() in %s on line %d
+NULL
+===Done===
--- /dev/null
+--TEST--
+Test abs() function : usage variations - different data types as $number arg
+--FILE--
+<?php
+/* Prototype : number abs ( mixed $number )
+ * Description: Returns the absolute value of number.
+ * Source code: ext/standard/math.c
+ */
+
+/*
+ * Pass different data types as $number argument to abs() to test behaviour
+ */
+
+echo "*** Testing abs() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+ public function __toString() {
+ return "abs";
+ }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+abs
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $number argument
+$inputs = array(
+
+ // null data
+/*10*/ NULL,
+ null,
+
+ // boolean data
+/*12*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*16*/ "",
+ '',
+ array(),
+
+ // string data
+/*19*/ "abs",
+ 'abs',
+ $heredoc,
+
+ // object data
+/*22*/ new classA(),
+
+ // undefined data
+/*23*/ @$undefined_var,
+
+ // unset data
+/*24*/ @$unset_var,
+
+ // resource variable
+/*25*/ $fp
+);
+
+// loop through each element of $inputs to check the behavior of abs()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(abs($input) );
+ $iterator++;
+};
+
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing abs() : usage variations ***
+
+-- Iteration 1 --
+int(0)
+
+-- Iteration 2 --
+int(0)
+
+-- Iteration 3 --
+int(1)
+
+-- Iteration 4 --
+int(0)
+
+-- Iteration 5 --
+int(1)
+
+-- Iteration 6 --
+int(0)
+
+-- Iteration 7 --
+int(0)
+
+-- Iteration 8 --
+int(0)
+
+-- Iteration 9 --
+bool(false)
+
+-- Iteration 10 --
+int(0)
+
+-- Iteration 11 --
+int(0)
+
+-- Iteration 12 --
+int(0)
+
+-- Iteration 13 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+int(1)
+
+-- Iteration 14 --
+int(0)
+
+-- Iteration 15 --
+int(0)
+
+-- Iteration 16 --
+int(%d)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test atan2() function : usage variations - different data types as $y arg
+--INI--
+precision = 10
+--FILE--
+<?php
+/* Prototype : float atan2 ( float $y , float $x )
+ * Description: Arc tangent of two variables.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing atan2() : 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,
+ 12,
+ -12,
+ 2147483647,
+
+ // float data
+/*6*/ 10.5,
+ -10.5,
+ 1.234567e2,
+ 1.234567E-2,
+ .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 atan2()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(atan2($input, 23));
+ $iterator++;
+};
+
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing atan2() : usage variations ***
+
+-- Iteration 1 --
+float(0)
+
+-- Iteration 2 --
+float(0.04345089539)
+
+-- Iteration 3 --
+float(0.4808872802)
+
+-- Iteration 4 --
+float(-0.4808872802)
+
+-- Iteration 5 --
+float(1.570796316)
+
+-- Iteration 6 --
+float(0.4282641529)
+
+-- Iteration 7 --
+float(-0.4282641529)
+
+-- Iteration 8 --
+float(1.386607742)
+
+-- Iteration 9 --
+float(0.0005367682093)
+
+-- Iteration 10 --
+float(0.02173570684)
+
+-- Iteration 11 --
+float(0)
+
+-- Iteration 12 --
+float(0)
+
+-- Iteration 13 --
+float(0.04345089539)
+
+-- Iteration 14 --
+float(0)
+
+-- Iteration 15 --
+float(0.04345089539)
+
+-- Iteration 16 --
+float(0)
+
+-- Iteration 17 --
+float(0)
+
+-- Iteration 18 --
+float(0)
+
+-- Iteration 19 --
+float(0)
+
+-- Iteration 20 --
+float(0)
+
+-- Iteration 21 --
+float(0)
+
+-- Iteration 22 --
+float(0)
+
+-- Iteration 23 --
+
+Notice: Object of class classA could not be converted to double in %s on line %d
+float(0.04345089539)
+
+-- Iteration 24 --
+float(0)
+
+-- Iteration 25 --
+float(0)
+
+-- Iteration 26 --
+float(%f)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test atan2() function : usage variations - different data types as $x arg
+--INI--
+precision = 10
+--FILE--
+<?php
+/* Prototype : float atan2 ( float $y , float $x )
+ * Description: Arc tangent of two variables.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing atan2() : basic functionality ***\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,
+ 12,
+ -12,
+ 2147483647,
+
+ // float data
+/*6*/ 10.5,
+ -10.5,
+ 1.234567e2,
+ 1.234567E-2,
+ .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 atan2()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(atan2(23, $input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing atan2() : basic functionality ***
+
+-- Iteration 1 --
+float(1.570796327)
+
+-- Iteration 2 --
+float(1.527345431)
+
+-- Iteration 3 --
+float(1.089909047)
+
+-- Iteration 4 --
+float(2.051683607)
+
+-- Iteration 5 --
+float(1.071020961E-8)
+
+-- Iteration 6 --
+float(1.142532174)
+
+-- Iteration 7 --
+float(1.99906048)
+
+-- Iteration 8 --
+float(0.1841885846)
+
+-- Iteration 9 --
+float(1.570259559)
+
+-- Iteration 10 --
+float(1.54906062)
+
+-- Iteration 11 --
+float(1.570796327)
+
+-- Iteration 12 --
+float(1.570796327)
+
+-- Iteration 13 --
+float(1.527345431)
+
+-- Iteration 14 --
+float(1.570796327)
+
+-- Iteration 15 --
+float(1.527345431)
+
+-- Iteration 16 --
+float(1.570796327)
+
+-- Iteration 17 --
+float(1.570796327)
+
+-- Iteration 18 --
+float(1.570796327)
+
+-- Iteration 19 --
+float(1.570796327)
+
+-- Iteration 20 --
+float(1.570796327)
+
+-- Iteration 21 --
+float(1.570796327)
+
+-- Iteration 22 --
+float(1.570796327)
+
+-- Iteration 23 --
+
+Notice: Object of class classA could not be converted to double in %s on line %d
+float(1.527345431)
+
+-- Iteration 24 --
+float(1.570796327)
+
+-- Iteration 25 --
+float(1.570796327)
+
+-- Iteration 26 --
+float(%f)
+===Done===
\ No newline at end of file
--TEST--
-Test base_convert() - wrong params base_convert()
+Test base_convert() function : error conditions - incorrect input
--FILE--
<?php
+/* Prototype : string base_convert ( string $number , int $frombase , int $tobase )
+ * Description: Convert a number between arbitrary bases.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing base_convert() : error conditions ***\n";
+
+// get a class
+class classA
+{
+}
+
+echo "Incorrect number of arguments\n";
base_convert();
base_convert(35);
base_convert(35,2);
base_convert(1234, 1, 10);
base_convert(1234, 10, 37);
+
+echo "Incorrect input\n";
+base_convert(new classA(), 8, 10);
+
?>
--EXPECTF--
+*** Testing base_convert() : error conditions ***
+Incorrect number of arguments
+
+Warning: Wrong parameter count for base_convert() in %s on line %d
-Warning: Wrong parameter count for base_convert() in %s on line 2
+Warning: Wrong parameter count for base_convert() in %s on line %d
-Warning: Wrong parameter count for base_convert() in %s on line 3
+Warning: Wrong parameter count for base_convert() in %s on line %d
-Warning: Wrong parameter count for base_convert() in %s on line 4
+Warning: base_convert(): Invalid `from base' (1) in %s on line %d
-Warning: base_convert(): Invalid `from base' (1) in %s on line 5
+Warning: base_convert(): Invalid `to base' (37) in %s on line %d
+Incorrect input
-Warning: base_convert(): Invalid `to base' (37) in %s on line 6
+Catchable fatal error: Object of class classA could not be converted to string in %s on line %d
--- /dev/null
+--TEST--
+Test base_convert() function : usage variations - different data types as $number argument
+--FILE--
+<?php
+/* Prototype : string base_convert ( string $number , int $frombase , int $tobase )
+ * Description: Convert a number between arbitrary bases.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing base_convert() : 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,
+ 12,
+ -12,
+ 2147483647,
+
+ // float data
+/*6*/ 10.5,
+ -10.5,
+ 1.234567e2,
+ 1.234567E-2,
+ .5,
+
+ // null data
+/*11*/ NULL,
+ null,
+
+ // boolean data
+/*13*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*17*/ "",
+ '',
+ array(),
+
+ // string data
+/*20*/ "abcxyz",
+ 'abcxyz',
+ $heredoc,
+
+ // undefined data
+/*23*/ @$undefined_var,
+
+ // unset data
+/*24*/ @$unset_var,
+
+ // resource variable
+/*25*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of base_convert()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(base_convert($input, 10, 8));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing base_convert() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(2) "14"
+
+-- Iteration 4 --
+string(2) "14"
+
+-- Iteration 5 --
+string(11) "17777777777"
+
+-- Iteration 6 --
+string(3) "151"
+
+-- Iteration 7 --
+string(3) "151"
+
+-- Iteration 8 --
+string(7) "4553207"
+
+-- Iteration 9 --
+string(7) "4553207"
+
+-- Iteration 10 --
+string(1) "5"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "1"
+
+-- Iteration 14 --
+string(1) "0"
+
+-- Iteration 15 --
+string(1) "1"
+
+-- Iteration 16 --
+string(1) "0"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+
+Notice: Array to string conversion in %s on line %d
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+string(1) "0"
+
+-- Iteration 25 --
+string(%d) "%d"
+===Done===
--- /dev/null
+--TEST--
+Test base_convert() function : usage variations - different data types as $frombase argument
+--FILE--
+<?php
+/* Prototype : string base_convert ( string $number , int $frombase , int $tobase )
+ * Description: Convert a number between arbitrary bases.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing base_convert() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+$inputs = array(
+ // int data
+/*1*/ 0,
+ 1,
+ -1,
+ -12,
+ 2147483647,
+
+ // float data
+/*6*/ 10.5,
+ -10.5,
+ 1.234567e2,
+ 1.234567E-2,
+ .5,
+
+ // null data
+/*11*/ NULL,
+ null,
+
+ // boolean data
+/*13*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*17*/ "",
+ '',
+ array(),
+
+ // string data
+/*20*/ "abcxyz",
+ 'abcxyz',
+ $heredoc,
+
+ // undefined data
+/*23*/ @$undefined_var,
+
+ // unset data
+/*24*/ @$unset_var,
+);
+
+// loop through each element of $inputs to check the behaviour of base_convert()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(base_convert(25, $input, 8));
+ $iterator++;
+};
+?>
+===Done===
+--EXPECTF--
+*** Testing base_convert() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: base_convert(): Invalid `from base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: base_convert(): Invalid `from base' (-1) in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: base_convert(): Invalid `from base' (-12) in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: base_convert(): Invalid `from base' (2147483647) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+string(2) "31"
+
+-- Iteration 7 --
+
+Warning: base_convert(): Invalid `from base' (-10) in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: base_convert(): Invalid `from base' (123) in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: base_convert(): Invalid `from base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: base_convert(): Invalid `from base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 19 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: base_convert(): Invalid `from base' (0) in %s on line %d
+bool(false)
+===Done===
--- /dev/null
+--TEST--
+Test base_convert() function : usage variations - different data types as $tobase argument
+--FILE--
+<?php
+/* Prototype : string base_convert ( string $number , int $frombase , int $tobase )
+ * Description: Convert a number between arbitrary bases.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing base_convert() : usage variations ***\n";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+abc
+xyz
+EOT;
+
+$inputs = array(
+ // int data
+/*1*/ 0,
+ 1,
+ -1,
+ -12,
+ 2147483647,
+
+ // float data
+/*6*/ 10.5,
+ -10.5,
+ 1.234567e2,
+ 1.234567E-2,
+ .5,
+
+ // null data
+/*11*/ NULL,
+ null,
+
+ // boolean data
+/*13*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*17*/ "",
+ '',
+ array(),
+
+ // string data
+/*20*/ "abcxyz",
+ 'abcxyz',
+ $heredoc,
+
+ // undefined data
+/*23*/ @$undefined_var,
+
+ // unset data
+/*24*/ @$unset_var,
+);
+
+// loop through each element of $inputs to check the behaviour of base_convert()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(base_convert(25, 10, $input));
+ $iterator++;
+};
+?>
+===Done===
+--EXPECTF--
+*** Testing base_convert() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: base_convert(): Invalid `to base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: base_convert(): Invalid `to base' (-1) in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: base_convert(): Invalid `to base' (-12) in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: base_convert(): Invalid `to base' (2147483647) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+string(2) "25"
+
+-- Iteration 7 --
+
+Warning: base_convert(): Invalid `to base' (-10) in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: base_convert(): Invalid `to base' (123) in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: base_convert(): Invalid `to base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: base_convert(): Invalid `to base' (1) in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 19 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: base_convert(): Invalid `to base' (0) in %s on line %d
+bool(false)
+===Done===
--TEST--
-Test bindec() - basic function test bindec()
+Test bindec() function : error conditions - incorrect input
--FILE--
<?php
+/* Prototype : number bindec ( string $binary_string )
+ * Description: Returns the decimal equivalent of the binary number represented by the binary_string argument.
+ * Source code: ext/standard/math.c
+ */
+
+/*
+ * Pass incorrect input to bindec() to test behaviour
+ */
+
+echo "*** Testing bindec() : error conditions ***\n";
+
+// get a class
+class classA
+{
+}
+
+echo "Incorrect number of arguments\n";
bindec();
bindec('01010101111',true);
+
+echo "Incorrect input\n";
+bindec(new classA());
?>
--EXPECTF--
+*** Testing bindec() : error conditions ***
+Incorrect number of arguments
+
+Warning: Wrong parameter count for bindec() in %s on line %d
-Warning: Wrong parameter count for bindec() in %s on line 2
+Warning: Wrong parameter count for bindec() in %s on line %d
+Incorrect input
-Warning: Wrong parameter count for bindec() in %s on line 3
+Catchable fatal error: Object of class classA could not be converted to string in %s on line %d
--- /dev/null
+--TEST--
+Test bindec() function : usage variations - different data types as $binary_string arg
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype : number bindec ( string $binary_string )
+ * Description: Returns the decimal equivalent of the binary number represented by the binary_string argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing bindec() : 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,
+
+ // float data
+/*5*/ 10.5,
+ -10.5,
+ 12.3456789000e10,
+ 12.3456789000E-10,
+ .5,
+
+ // null data
+/*10*/ NULL,
+ null,
+
+ // boolean data
+/*12*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*16*/ "",
+ '',
+ array(),
+
+ // string data
+/*19*/ "abcxyz",
+ 'abcxyz',
+ $heredoc,
+
+ // undefined data
+/*22*/ @$undefined_var,
+
+ // unset data
+/*23*/ @$unset_var,
+
+ // resource variable
+/*24*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of bindec()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(bindec($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing bindec() : usage variations ***
+
+-- Iteration 1 --
+int(0)
+
+-- Iteration 2 --
+int(1)
+
+-- Iteration 3 --
+int(1)
+
+-- Iteration 4 --
+int(0)
+
+-- Iteration 5 --
+int(2)
+
+-- Iteration 6 --
+int(2)
+
+-- Iteration 7 --
+int(8)
+
+-- Iteration 8 --
+int(1)
+
+-- Iteration 9 --
+int(0)
+
+-- Iteration 10 --
+int(0)
+
+-- Iteration 11 --
+int(0)
+
+-- Iteration 12 --
+int(1)
+
+-- Iteration 13 --
+int(0)
+
+-- Iteration 14 --
+int(1)
+
+-- Iteration 15 --
+int(0)
+
+-- Iteration 16 --
+int(0)
+
+-- Iteration 17 --
+int(0)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+int(0)
+
+-- Iteration 19 --
+int(0)
+
+-- Iteration 20 --
+int(0)
+
+-- Iteration 21 --
+int(0)
+
+-- Iteration 22 --
+int(0)
+
+-- Iteration 23 --
+int(0)
+
+-- Iteration 24 --
+int(%d)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test bindec() function : usage variations - different data types as $binary_string arg
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype : number bindec ( string $binary_string )
+ * Description: Returns the decimal equivalent of the binary number represented by the binary_string argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing bindec() : 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,
+
+ // float data
+/*5*/ 10.5,
+ -10.5,
+ 12.3456789000e10,
+ 12.3456789000E-10,
+ .5,
+
+ // null data
+/*10*/ NULL,
+ null,
+
+ // boolean data
+/*12*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*16*/ "",
+ '',
+ array(),
+
+ // string data
+/*19*/ "abcxyz",
+ 'abcxyz',
+ $heredoc,
+
+ // undefined data
+/*22*/ @$undefined_var,
+
+ // unset data
+/*23*/ @$unset_var,
+
+ // resource variable
+/*24*/ $fp
+);
+
+// loop through each element of $inputs to check the behaviour of bindec()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(bindec($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing bindec() : usage variations ***
+
+-- Iteration 1 --
+int(0)
+
+-- Iteration 2 --
+int(1)
+
+-- Iteration 3 --
+int(1)
+
+-- Iteration 4 --
+int(0)
+
+-- Iteration 5 --
+int(2)
+
+-- Iteration 6 --
+int(2)
+
+-- Iteration 7 --
+int(8)
+
+-- Iteration 8 --
+int(1)
+
+-- Iteration 9 --
+int(0)
+
+-- Iteration 10 --
+int(0)
+
+-- Iteration 11 --
+int(0)
+
+-- Iteration 12 --
+int(1)
+
+-- Iteration 13 --
+int(0)
+
+-- Iteration 14 --
+int(1)
+
+-- Iteration 15 --
+int(0)
+
+-- Iteration 16 --
+int(0)
+
+-- Iteration 17 --
+int(0)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+int(0)
+
+-- Iteration 19 --
+int(0)
+
+-- Iteration 20 --
+int(0)
+
+-- Iteration 21 --
+int(0)
+
+-- Iteration 22 --
+int(0)
+
+-- Iteration 23 --
+int(0)
+
+-- Iteration 24 --
+int(%d)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test ceil() - basic function test for ceil()
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype : float ceil ( float $value )
+ * Description: Round fractions up.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing ceil() : 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,
+ );
+
+for ($i = 0; $i < count($values); $i++) {
+ $res = ceil($values[$i]);
+ var_dump($res);
+}
+
+?>
+===Done===
+--EXPECTF--
+*** Testing ceil() : basic functionality ***
+float(0)
+float(0)
+float(1)
+float(-0)
+float(1)
+float(-1)
+float(2)
+float(-1)
+float(3)
+float(-2)
+float(31)
+float(95)
+float(11)
+float(-10)
+float(3950)
+float(-3950)
+float(39)
+float(95)
+float(1)
+float(0)
+float(0)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test ceil() - error conditions - incorrect number of args
+--FILE--
+<?php
+/* Prototype : float ceil ( float $value )
+ * Description: Round fractions up.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing ceil() : error conditions ***\n";
+$arg_0 = 1.0;
+$extra_arg = 1;
+
+echo "\nToo many arguments\n";
+var_dump(ceil($arg_0, $extra_arg));
+
+echo "\nToo few arguments\n";
+var_dump(ceil());
+?>
+===Done===
+--EXPECTF--
+*** Testing ceil() : error conditions ***
+
+Too many arguments
+
+Warning: Wrong parameter count for ceil() in %s on line %d
+NULL
+
+Too few arguments
+
+Warning: Wrong parameter count for ceil() in %s on line %d
+NULL
+===Done===
--- /dev/null
+--TEST--
+Test ceil() function : usage variations - different data types as $value arg
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype : float ceil ( float $value )
+ * Description: Round fractions up.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing ceil() : 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 ceil()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(ceil($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing ceil() : 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===
--TEST--
-Test decbin() - wrong params
+Test decbin() - error conditions
--FILE--
<?php
+/* Prototype : string decbin ( int $number )
+ * Description: Decimal to binary.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decbin() : error conditions ***\n";
+
+echo "Incorrect number of arguments\n";
decbin();
decbin(23,2,true);
+
?>
+===Done===
--EXPECTF--
+*** Testing decbin() : error conditions ***
+Incorrect number of arguments
-Warning: Wrong parameter count for decbin() in %s on line 2
-
-Warning: Wrong parameter count for decbin() in %s on line 3
+Warning: Wrong parameter count for decbin() in %s on line %d
+Warning: Wrong parameter count for decbin() in %s on line %d
+===Done===
--- /dev/null
+--TEST--
+Test decbin() 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 : string decbin ( int $number )
+ * Description: Decimal to binary.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decbin() : 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,
+ 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,
+
+ // 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 decbin()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(decbin($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing decbin() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(14) "11000000111001"
+
+-- Iteration 4 --
+string(32) "11111111111111111111011011010111"
+
+-- Iteration 5 --
+string(32) "11111111111111111111111111111111"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(4) "1010"
+
+-- Iteration 8 --
+string(32) "11111111111111111111111111110110"
+
+-- Iteration 9 --
+string(32) "10111110100110010001101000001000"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%d"
+===Done===
--- /dev/null
+--TEST--
+Test decbin() 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 : string decbin ( int $number )
+ * Description: Decimal to binary.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decbin() : 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,
+ 18446744073709551615, // largest decimal
+ 18446744073709551616,
+
+ // 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,
+
+ // 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 decbin()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(decbin($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing decbin() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(14) "11000000111001"
+
+-- Iteration 4 --
+string(64) "1111111111111111111111111111111111111111111111111111011011010111"
+
+-- Iteration 5 --
+string(1) "0"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(4) "1010"
+
+-- Iteration 8 --
+string(64) "1111111111111111111111111111111111111111111111111111111111110110"
+
+-- Iteration 9 --
+string(37) "1110010111110100110010001101000001000"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%d"
+===Done===
\ No newline at end of file
Test dechex() - wrong params dechex()
--FILE--
<?php
+/* Prototype : string dechex ( int $number )
+ * Description: Returns a string containing a hexadecimal representation of the given number argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing dechex() : error conditions ***\n";
+
+echo "\nIncorrect number of arguments\n";
dechex();
dechex(23,2,true);
-?>
+?>
+===Done===
--EXPECTF--
+*** Testing dechex() : error conditions ***
+
+Incorrect number of arguments
-Warning: Wrong parameter count for dechex() in %s on line 2
+Warning: Wrong parameter count for dechex() in %s on line %d
-Warning: Wrong parameter count for dechex() in %s on line 3
+Warning: Wrong parameter count for dechex() in %s on line %d
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test dechex() 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 : string dechex ( int $number )
+ * Description: Returns a string containing a hexadecimal representation of the given number argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing dechex() : 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,
+ 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,
+
+ // 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 dechex()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(dechex($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing dechex() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(4) "3039"
+
+-- Iteration 4 --
+string(8) "fffff6d7"
+
+-- Iteration 5 --
+string(8) "ffffffff"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(1) "a"
+
+-- Iteration 8 --
+string(8) "fffffff6"
+
+-- Iteration 9 --
+string(8) "be991a08"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%s"
+===Done===
--- /dev/null
+--TEST--
+Test dechex() 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 : string dechex ( int $number )
+ * Description: Returns a string containing a hexadecimal representation of the given number argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing dechex() : 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,
+ 18446744073709551615, // largest decimal
+ 18446744073709551616,
+
+ // 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,
+
+ // 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 dechex()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(dechex($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing dechex() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(4) "3039"
+
+-- Iteration 4 --
+string(16) "fffffffffffff6d7"
+
+-- Iteration 5 --
+string(1) "0"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(1) "a"
+
+-- Iteration 8 --
+string(16) "fffffffffffffff6"
+
+-- Iteration 9 --
+string(10) "1cbe991a08"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%s"
+===Done===
\ No newline at end of file
--TEST--
-Test decoct() - wrong params decoct()
+Test decoct() - error conditions
--FILE--
<?php
+/* Prototype : string decbin ( int $number )
+ * Description: Decimal to binary.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decoct() : error conditions ***\n";
+
+echo "Incorrect number of arguments\n";
decoct();
decoct(23,2,true);
+
?>
+===Done===
--EXPECTF--
+*** Testing decoct() : error conditions ***
+Incorrect number of arguments
-Warning: Wrong parameter count for decoct() in %s on line 2
-
-Warning: Wrong parameter count for decoct() in %s on line 3
+Warning: Wrong parameter count for decoct() in %s on line %d
+Warning: Wrong parameter count for decoct() in %s on line %d
+===Done===
--- /dev/null
+--TEST--
+Test decoct() 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 : string decoct ( int $number )
+ * Description: Returns a string containing an octal representation of the given number argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decoct() : 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,
+ 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,
+
+ // 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 decoct()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(decoct($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing decoct() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(5) "30071"
+
+-- Iteration 4 --
+string(11) "37777773327"
+
+-- Iteration 5 --
+string(11) "37777777777"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(2) "12"
+
+-- Iteration 8 --
+string(11) "37777777766"
+
+-- Iteration 9 --
+string(11) "27646215010"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%d"
+===Done===
--- /dev/null
+--TEST--
+Test decoct() 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 : string decoct ( int $number )
+ * Description: Returns a string containing an octal representation of the given number argument.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing decoct() : 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,
+ 18446744073709551615, // largest decimal
+ 18446744073709551616,
+
+ // 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,
+
+ // 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 decoct()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(decoct($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing decoct() : usage variations ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(1) "1"
+
+-- Iteration 3 --
+string(5) "30071"
+
+-- Iteration 4 --
+string(22) "1777777777777777773327"
+
+-- Iteration 5 --
+string(1) "0"
+
+-- Iteration 6 --
+string(1) "0"
+
+-- Iteration 7 --
+string(2) "12"
+
+-- Iteration 8 --
+string(22) "1777777777777777777766"
+
+-- Iteration 9 --
+string(13) "1627646215010"
+
+-- Iteration 10 --
+string(1) "0"
+
+-- Iteration 11 --
+string(1) "0"
+
+-- Iteration 12 --
+string(1) "0"
+
+-- Iteration 13 --
+string(1) "0"
+
+-- Iteration 14 --
+string(1) "1"
+
+-- Iteration 15 --
+string(1) "0"
+
+-- Iteration 16 --
+string(1) "1"
+
+-- Iteration 17 --
+string(1) "0"
+
+-- Iteration 18 --
+string(1) "0"
+
+-- Iteration 19 --
+string(1) "0"
+
+-- Iteration 20 --
+string(1) "0"
+
+-- Iteration 21 --
+string(1) "0"
+
+-- Iteration 22 --
+string(1) "0"
+
+-- Iteration 23 --
+string(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+string(1) "1"
+
+-- Iteration 25 --
+string(1) "0"
+
+-- Iteration 26 --
+string(1) "0"
+
+-- Iteration 27 --
+string(%d) "%d"
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test exp() - basic function test for exp()
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype : float exp ( float $arg )
+ * Description: Returns e raised to the power of arg.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing exp() : 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 exp()
+$iterator = 1;
+foreach($values as $value) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(exp($value));
+ $iterator++;
+};
+?>
+===Done===
+--EXPECTF--
+*** Testing exp() : basic functionality ***
+
+-- Iteration 1 --
+float(22026.465794807)
+
+-- Iteration 2 --
+float(29732.618852891)
+
+-- Iteration 3 --
+float(INF)
+
+-- Iteration 4 --
+float(29048849665247)
+
+-- Iteration 5 --
+float(1.811239082889E+41)
+
+-- Iteration 6 --
+float(22026.465794807)
+
+-- Iteration 7 --
+float(INF)
+
+-- Iteration 8 --
+float(INF)
+
+-- Iteration 9 --
+float(8.6593400423994E+16)
+
+-- Iteration 10 --
+float(1.811239082889E+41)
+
+-- Iteration 11 --
+float(2.718281828459)
+
+-- Iteration 12 --
+float(1)
+
+-- Iteration 13 --
+float(1)
+===Done===
\ No newline at end of file
--- /dev/null
+--TEST--
+Test exp() function : usage variations - different data types as $arg argument
+--INI--
+precision=14
+--FILE--
+<?php
+/* Prototype : float exp ( float $arg )
+ * Description: Returns e raised to the power of arg.
+ * Source code: ext/standard/math.c
+ */
+
+echo "*** Testing exp() : 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 exp()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump(exp($input));
+ $iterator++;
+};
+fclose($fp);
+?>
+===Done===
+--EXPECTF--
+*** Testing exp() : usage variations ***
+
+-- Iteration 1 --
+float(1)
+
+-- Iteration 2 --
+float(2.718281828459)
+
+-- Iteration 3 --
+float(INF)
+
+-- Iteration 4 --
+float(0)
+
+-- Iteration 5 --
+float(INF)
+
+-- Iteration 6 --
+float(36315.502674247)
+
+-- Iteration 7 --
+float(2.7536449349747E-5)
+
+-- Iteration 8 --
+float(INF)
+
+-- Iteration 9 --
+float(1.0000000012346)
+
+-- Iteration 10 --
+float(1.6487212707001)
+
+-- Iteration 11 --
+float(1)
+
+-- Iteration 12 --
+float(1)
+
+-- Iteration 13 --
+float(2.718281828459)
+
+-- Iteration 14 --
+float(1)
+
+-- Iteration 15 --
+float(2.718281828459)
+
+-- Iteration 16 --
+float(1)
+
+-- Iteration 17 --
+
+Warning: exp() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: exp() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: exp() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: exp() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: exp() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: exp() expects parameter 1 to be double, string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: exp() expects parameter 1 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(1)
+
+-- Iteration 25 --
+float(1)
+
+-- Iteration 26 --
+
+Warning: exp() expects parameter 1 to be double, resource given in %s on line %d
+NULL
+===Done===