]> granicus.if.org Git - php/commitdiff
New PHPT tests for math functions. Tested on Windows, Linux and Linux 64 bit.
authorandy wharmby <wharmby@php.net>
Thu, 8 Jan 2009 21:18:37 +0000 (21:18 +0000)
committerandy wharmby <wharmby@php.net>
Thu, 8 Jan 2009 21:18:37 +0000 (21:18 +0000)
26 files changed:
ext/standard/tests/math/abs_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/abs_error.phpt [new file with mode: 0644]
ext/standard/tests/math/abs_variation.phpt [new file with mode: 0644]
ext/standard/tests/math/atan2_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/atan2_variation2.phpt [new file with mode: 0644]
ext/standard/tests/math/base_convert_error.phpt
ext/standard/tests/math/base_convert_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/base_convert_variation2.phpt [new file with mode: 0644]
ext/standard/tests/math/base_convert_variation3.phpt [new file with mode: 0644]
ext/standard/tests/math/bindec_error.phpt
ext/standard/tests/math/bindec_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/bindec_variation1_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/ceil_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/ceil_error.phpt [new file with mode: 0644]
ext/standard/tests/math/ceil_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/decbin_error.phpt
ext/standard/tests/math/decbin_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/decbin_variation1_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/dechex_error.phpt
ext/standard/tests/math/dechex_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/dechex_variation1_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/decoct_error.phpt
ext/standard/tests/math/decoct_variation1.phpt [new file with mode: 0644]
ext/standard/tests/math/decoct_variation1_64bit.phpt [new file with mode: 0644]
ext/standard/tests/math/exp_basic.phpt [new file with mode: 0644]
ext/standard/tests/math/exp_variation1.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/math/abs_basic.phpt b/ext/standard/tests/math/abs_basic.phpt
new file mode 100644 (file)
index 0000000..0f6ecbc
--- /dev/null
@@ -0,0 +1,51 @@
+--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
diff --git a/ext/standard/tests/math/abs_error.phpt b/ext/standard/tests/math/abs_error.phpt
new file mode 100644 (file)
index 0000000..4d62259
--- /dev/null
@@ -0,0 +1,39 @@
+--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: abs() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Too few arguments
+
+Warning: abs() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/abs_variation.phpt b/ext/standard/tests/math/abs_variation.phpt
new file mode 100644 (file)
index 0000000..6df1e6b
--- /dev/null
@@ -0,0 +1,135 @@
+--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
diff --git a/ext/standard/tests/math/atan2_variation1.phpt b/ext/standard/tests/math/atan2_variation1.phpt
new file mode 100644 (file)
index 0000000..1369e55
--- /dev/null
@@ -0,0 +1,187 @@
+--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 --
+
+Warning: atan2() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: atan2() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: atan2() expects parameter 1 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: atan2() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: atan2() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: atan2() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: atan2() 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: atan2() 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/atan2_variation2.phpt b/ext/standard/tests/math/atan2_variation2.phpt
new file mode 100644 (file)
index 0000000..166c8d2
--- /dev/null
@@ -0,0 +1,186 @@
+--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 --
+
+Warning: atan2() expects parameter 2 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: atan2() expects parameter 2 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: atan2() expects parameter 2 to be double, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: atan2() expects parameter 2 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: atan2() expects parameter 2 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: atan2() expects parameter 2 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: atan2() expects parameter 2 to be double, object given in %s on line %d
+NULL
+
+-- Iteration 24 --
+float(1.570796327)
+
+-- Iteration 25 --
+float(1.570796327)
+
+-- Iteration 26 --
+
+Warning: atan2() expects parameter 2 to be double, resource given in %s on line %d
+NULL
+===Done===
\ No newline at end of file
index 5614073944c9d66d29bdb4be618814e6fa68088f..c9b51088aa3121056b0564d4f67b7de9ec69f1d9 100644 (file)
@@ -1,14 +1,33 @@
 --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: base_convert() expects exactly 3 parameters, 0 given in %s on line %d
 
@@ -18,4 +37,7 @@ Warning: base_convert() expects exactly 3 parameters, 2 given in %s on line %d
 
 Warning: base_convert(): Invalid `from base' (1) in %s on line %d
 
-Warning: base_convert(): Invalid `to base' (37) in %s on line %d
+Warning: base_convert(): Invalid `to base' (37) in %s on line %s
+Incorrect input
+
+Catchable fatal error: Object of class classA could not be converted to binary string in %s on line %d
\ No newline at end of file
diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt
new file mode 100644 (file)
index 0000000..3ea711a
--- /dev/null
@@ -0,0 +1,159 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(2) "14"
+
+-- Iteration 4 --
+unicode(2) "14"
+
+-- Iteration 5 --
+unicode(11) "17777777777"
+
+-- Iteration 6 --
+unicode(3) "151"
+
+-- Iteration 7 --
+unicode(3) "151"
+
+-- Iteration 8 --
+unicode(7) "4553207"
+
+-- Iteration 9 --
+unicode(7) "4553207"
+
+-- Iteration 10 --
+unicode(1) "5"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "1"
+
+-- Iteration 14 --
+unicode(1) "0"
+
+-- Iteration 15 --
+unicode(1) "1"
+
+-- Iteration 16 --
+unicode(1) "0"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+
+Notice: Array to string conversion in %s on line %d
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+unicode(1) "0"
+
+-- Iteration 25 --
+unicode(%d) "%d"
+===Done===
diff --git a/ext/standard/tests/math/base_convert_variation2.phpt b/ext/standard/tests/math/base_convert_variation2.phpt
new file mode 100644 (file)
index 0000000..a3b6576
--- /dev/null
@@ -0,0 +1,193 @@
+--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 --
+unicode(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() expects parameter 2 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: base_convert() expects parameter 2 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: base_convert() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: base_convert() expects parameter 2 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: base_convert() expects parameter 2 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: base_convert() expects parameter 2 to be long, Unicode string given in %s on line %d
+NULL
+
+-- 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===
\ No newline at end of file
diff --git a/ext/standard/tests/math/base_convert_variation3.phpt b/ext/standard/tests/math/base_convert_variation3.phpt
new file mode 100644 (file)
index 0000000..0b5acb6
--- /dev/null
@@ -0,0 +1,193 @@
+--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 --
+unicode(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() expects parameter 3 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: base_convert() expects parameter 3 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: base_convert() expects parameter 3 to be long, array given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: base_convert() expects parameter 3 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: base_convert() expects parameter 3 to be long, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: base_convert() expects parameter 3 to be long, Unicode string given in %s on line %d
+NULL
+
+-- 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===
\ No newline at end of file
index 1cf313f5204f10da2ec923994ec8d68e84465c86..0a1cf85e46d4ff1dce1e4b850ac60e9e9539bf0b 100644 (file)
@@ -1,12 +1,37 @@
 --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: bindec() expects exactly 1 parameter, 0 given in %s on line %d
 
 Warning: bindec() 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 binary string in %s on line %d
\ No newline at end of file
diff --git a/ext/standard/tests/math/bindec_variation1.phpt b/ext/standard/tests/math/bindec_variation1.phpt
new file mode 100644 (file)
index 0000000..1e188ba
--- /dev/null
@@ -0,0 +1,158 @@
+--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
diff --git a/ext/standard/tests/math/bindec_variation1_64bit.phpt b/ext/standard/tests/math/bindec_variation1_64bit.phpt
new file mode 100644 (file)
index 0000000..0a37c4c
--- /dev/null
@@ -0,0 +1,158 @@
+--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
diff --git a/ext/standard/tests/math/ceil_basic.phpt b/ext/standard/tests/math/ceil_basic.phpt
new file mode 100644 (file)
index 0000000..4264b1c
--- /dev/null
@@ -0,0 +1,66 @@
+--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
diff --git a/ext/standard/tests/math/ceil_error.phpt b/ext/standard/tests/math/ceil_error.phpt
new file mode 100644 (file)
index 0000000..1cf7ce4
--- /dev/null
@@ -0,0 +1,33 @@
+--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: ceil() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Too few arguments
+
+Warning: ceil() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+===Done===
diff --git a/ext/standard/tests/math/ceil_variation1.phpt b/ext/standard/tests/math/ceil_variation1.phpt
new file mode 100644 (file)
index 0000000..7c1f859
--- /dev/null
@@ -0,0 +1,128 @@
+--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(%d)
+===Done===
index 7df4f12c3a378025a13c362716cd68847bdddc5c..d45a3b0128844f6288e759f02811e8d2fb2870e9 100644 (file)
@@ -1,12 +1,25 @@
 --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: decbin() expects exactly 1 parameter, 0 given in %s on line %d
 
 Warning: decbin() expects exactly 1 parameter, 3 given in %s on line %d
+===Done===
diff --git a/ext/standard/tests/math/decbin_variation1.phpt b/ext/standard/tests/math/decbin_variation1.phpt
new file mode 100644 (file)
index 0000000..d1e3f08
--- /dev/null
@@ -0,0 +1,179 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(14) "11000000111001"
+
+-- Iteration 4 --
+unicode(32) "11111111111111111111011011010111"
+
+-- Iteration 5 --
+unicode(32) "11111111111111111111111111111111"
+
+-- Iteration 6 --
+unicode(31) "1111111111111111111111111111111"
+
+-- Iteration 7 --
+unicode(4) "1010"
+
+-- Iteration 8 --
+unicode(32) "11111111111111111111111111110110"
+
+-- Iteration 9 --
+unicode(31) "1111111111111111111111111111111"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%d"
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt
new file mode 100644 (file)
index 0000000..09a96d1
--- /dev/null
@@ -0,0 +1,179 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(14) "11000000111001"
+
+-- Iteration 4 --
+unicode(64) "1111111111111111111111111111111111111111111111111111011011010111"
+
+-- Iteration 5 --
+unicode(63) "111111111111111111111111111111111111111111111111111111111111111"
+
+-- Iteration 6 --
+unicode(63) "111111111111111111111111111111111111111111111111111111111111111"
+
+-- Iteration 7 --
+unicode(4) "1010"
+
+-- Iteration 8 --
+unicode(64) "1111111111111111111111111111111111111111111111111111111111110110"
+
+-- Iteration 9 --
+unicode(37) "1110010111110100110010001101000001000"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%d"
+===Done===
\ No newline at end of file
index 81492a49c6d2de61fdc3c7ee7f80ebd73303d9bf..7ed0c4598cf3767e9638f384a8e93f22832e9b7d 100644 (file)
@@ -2,12 +2,25 @@
 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: dechex() expects exactly 1 parameter, 0 given in %s on line %d
 
 Warning: dechex() expects exactly 1 parameter, 3 given in %s on line %d
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/dechex_variation1.phpt b/ext/standard/tests/math/dechex_variation1.phpt
new file mode 100644 (file)
index 0000000..54080b0
--- /dev/null
@@ -0,0 +1,179 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(4) "3039"
+
+-- Iteration 4 --
+unicode(8) "fffff6d7"
+
+-- Iteration 5 --
+unicode(8) "ffffffff"
+
+-- Iteration 6 --
+unicode(8) "7fffffff"
+
+-- Iteration 7 --
+unicode(1) "a"
+
+-- Iteration 8 --
+unicode(8) "fffffff6"
+
+-- Iteration 9 --
+unicode(8) "7fffffff"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%s"
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt
new file mode 100644 (file)
index 0000000..929e759
--- /dev/null
@@ -0,0 +1,179 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(4) "3039"
+
+-- Iteration 4 --
+unicode(16) "fffffffffffff6d7"
+
+-- Iteration 5 --
+unicode(16) "7fffffffffffffff"
+
+-- Iteration 6 --
+unicode(16) "7fffffffffffffff"
+
+-- Iteration 7 --
+unicode(1) "a"
+
+-- Iteration 8 --
+unicode(16) "fffffffffffffff6"
+
+-- Iteration 9 --
+unicode(10) "1cbe991a08"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%s"
+===Done===
\ No newline at end of file
index 44212afb07d72bfbe1643bcb0cc42e9e80a3a1ea..d3f6699428ed3c3f47839d961942361205e1f659 100644 (file)
@@ -1,12 +1,25 @@
 --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: decoct() expects exactly 1 parameter, 0 given in %s on line %d
 
 Warning: decoct() expects exactly 1 parameter, 3 given in %s on line %d
+===Done===
diff --git a/ext/standard/tests/math/decoct_variation1.phpt b/ext/standard/tests/math/decoct_variation1.phpt
new file mode 100644 (file)
index 0000000..69982da
--- /dev/null
@@ -0,0 +1,180 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(5) "30071"
+
+-- Iteration 4 --
+unicode(11) "37777773327"
+
+-- Iteration 5 --
+unicode(11) "37777777777"
+
+-- Iteration 6 --
+unicode(11) "17777777777"
+
+-- Iteration 7 --
+unicode(2) "12"
+
+-- Iteration 8 --
+unicode(11) "37777777766"
+
+-- Iteration 9 --
+unicode(11) "17777777777"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%d"
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt
new file mode 100644 (file)
index 0000000..40eca6c
--- /dev/null
@@ -0,0 +1,180 @@
+--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 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(1) "1"
+
+-- Iteration 3 --
+unicode(5) "30071"
+
+-- Iteration 4 --
+unicode(22) "1777777777777777773327"
+
+-- Iteration 5 --
+unicode(21) "777777777777777777777"
+
+-- Iteration 6 --
+unicode(21) "777777777777777777777"
+
+-- Iteration 7 --
+unicode(2) "12"
+
+-- Iteration 8 --
+unicode(22) "1777777777777777777766"
+
+-- Iteration 9 --
+unicode(13) "1627646215010"
+
+-- Iteration 10 --
+unicode(1) "0"
+
+-- Iteration 11 --
+unicode(1) "0"
+
+-- Iteration 12 --
+unicode(1) "0"
+
+-- Iteration 13 --
+unicode(1) "0"
+
+-- Iteration 14 --
+unicode(1) "1"
+
+-- Iteration 15 --
+unicode(1) "0"
+
+-- Iteration 16 --
+unicode(1) "1"
+
+-- Iteration 17 --
+unicode(1) "0"
+
+-- Iteration 18 --
+unicode(1) "0"
+
+-- Iteration 19 --
+unicode(1) "0"
+
+-- Iteration 20 --
+unicode(1) "0"
+
+-- Iteration 21 --
+unicode(1) "0"
+
+-- Iteration 22 --
+unicode(1) "0"
+
+-- Iteration 23 --
+unicode(1) "0"
+
+-- Iteration 24 --
+
+Notice: Object of class classA could not be converted to int in %s on line %d
+unicode(1) "1"
+
+-- Iteration 25 --
+unicode(1) "0"
+
+-- Iteration 26 --
+unicode(1) "0"
+
+-- Iteration 27 --
+unicode(%d) "%d"
+===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/math/exp_basic.phpt b/ext/standard/tests/math/exp_basic.phpt
new file mode 100644 (file)
index 0000000..9526c66
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+Test exp() - basic function test for exp()
+--INI--
+precision=14
+--FILE--
+<?php
+$values = array(10,
+                               10.3,
+                               3.9505e3,
+                               037,
+                               0x5F,   
+                               "10",
+                               "3950.5",
+                               "3.9505e3",
+                               "039",
+                               "0x5F",
+                               true,
+                               false,
+                               null, 
+                               );      
+
+$iterator = 1;
+foreach($values as $value) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump(exp($value));
+       $iterator++;
+};
+
+?>
+===Done===
+--EXPECTF--
+
+-- 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
diff --git a/ext/standard/tests/math/exp_variation1.phpt b/ext/standard/tests/math/exp_variation1.phpt
new file mode 100644 (file)
index 0000000..790f0b3
--- /dev/null
@@ -0,0 +1,187 @@
+--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, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: exp() expects parameter 1 to be double, Unicode 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, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: exp() expects parameter 1 to be double, Unicode string given in %s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: exp() expects parameter 1 to be double, Unicode 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===