ilewis          Mon Nov 24 17:36:44 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/array   array_product_error.phpt 
                                        array_product_variation1.phpt 
                                        array_product_variation2.phpt 
                                        array_product_variation3.phpt 
                                        array_product_variation4.phpt 
                                        array_product_variation5.phpt 
  Log:
  Adding some tests for array_product
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_error.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_product_error.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_error.phpt   Mon Nov 24 
17:36:44 2008
@@ -0,0 +1,45 @@
+--TEST--
+Test array_product() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing array_product() function with Zero arguments --\n";
+var_dump( array_product() );
+
+//Test array_product with one more than the expected number of arguments
+echo "\n-- Testing array_product() function with more than expected no. of 
arguments --\n";
+$input = array(1, 2);
+$extra_arg = 10;
+var_dump( array_product($input, $extra_arg) );
+
+echo "\n-- Testing array_product() function incorrect argument type --\n";
+var_dump( array_product("bob") );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : error conditions ***
+
+-- Testing array_product() function with Zero arguments --
+
+Warning: array_product() expects exactly 1 parameter, 0 given in 
%sarray_product_error.php on line %d
+NULL
+
+-- Testing array_product() function with more than expected no. of arguments --
+
+Warning: array_product() expects exactly 1 parameter, 2 given in 
%sarray_product_error.php on line %d
+NULL
+
+-- Testing array_product() function incorrect argument type --
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_error.php on line %d
+NULL
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_product_variation1.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_variation1.phpt      Mon Nov 
24 17:36:44 2008
@@ -0,0 +1,58 @@
+--TEST--
+Test array_product() function : variation 
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : variation - using non numeric values 
***\n";
+
+class A {
+  static function help() { echo "hello\n"; }
+}
+$fp = fopen(__FILE__, "r");
+
+$types = array("boolean (true)" => true, "boolean (false)" => false, 
+       "string" => "hello", "numeric string" =>  "12",
+       "resource" => $fp, "object" => new A(), "null" => null,
+       "array" => array(3,2));
+
+foreach ($types as $desc => $type) {
+  echo $desc . "\n";
+  var_dump(array_product(array($type)));
+  echo "\n";
+}
+
+fclose($fp);
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : variation - using non numeric values ***
+boolean (true)
+int(1)
+
+boolean (false)
+int(0)
+
+string
+int(0)
+
+numeric string
+int(12)
+
+resource
+int(%d)
+
+object
+int(1)
+
+null
+int(0)
+
+array
+int(1)
+
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_product_variation2.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_variation2.phpt      Mon Nov 
24 17:36:44 2008
@@ -0,0 +1,22 @@
+--TEST--
+Test array_product() function : variation - using a keyed array
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : variations ***\n";
+
+echo "\n-- Testing array_product() function with a keyed array --\n";
+var_dump( array_product(array("bob" => 2, "janet" => 5)) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : variations ***
+
+-- Testing array_product() function with a keyed array --
+int(10)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_product_variation3.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_variation3.phpt      Mon Nov 
24 17:36:44 2008
@@ -0,0 +1,48 @@
+--TEST--
+Test array_product() function : variation - negative numbers
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : variations - negative numbers***\n";
+
+echo "\n-- Testing array_product() function with one negative number --\n";
+var_dump( array_product(array(-2)) );
+
+echo "\n-- Testing array_product() function with two negative numbers --\n";
+var_dump( array_product(array(-2, -3)) );
+
+echo "\n-- Testing array_product() function with three negative numbers --\n";
+var_dump( array_product(array(-2, -3, -4)) );
+
+echo "\n-- Testing array_product() function with negative floats --\n";
+var_dump( array_product(array(-1.5)));
+
+echo "\n-- Testing array_product() function with negative floats --\n";
+var_dump( array_product(array(-99999999.9, 99999999.1)));
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : variations - negative numbers***
+
+-- Testing array_product() function with one negative number --
+int(-2)
+
+-- Testing array_product() function with two negative numbers --
+int(6)
+
+-- Testing array_product() function with three negative numbers --
+int(-24)
+
+-- Testing array_product() function with negative floats --
+float(-1.5)
+
+-- Testing array_product() function with negative floats --
+float(-9.9999999E+15)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_product_variation4.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_variation4.phpt      Mon Nov 
24 17:36:44 2008
@@ -0,0 +1,29 @@
+--TEST--
+Test array_product() function : variation - testing with a very large array
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : variations ***\n";
+
+echo "\n-- Testing array_product() function with a very large array --\n";
+
+$array = array();
+
+for ($i = 0; $i < 999; $i++) {
+  $array[] = 999;
+}
+
+var_dump( array_product($array) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : variations ***
+
+-- Testing array_product() function with a very large array --
+float(INF)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_product_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_product_variation5.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_product_variation5.phpt:1.2
--- /dev/null   Mon Nov 24 17:36:44 2008
+++ php-src/ext/standard/tests/array/array_product_variation5.phpt      Mon Nov 
24 17:36:44 2008
@@ -0,0 +1,223 @@
+--TEST--
+Test array_product() function : usage variation 
+--FILE--
+<?php
+/* Prototype  : mixed array_product(array input)
+ * Description: Returns the product of the array entries 
+ * Source code: ext/standard/array.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing array_product() : usage variation ***\n";
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for input
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( array_product($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_product() : usage variation ***
+
+--int 0--
+
+Warning: array_product() expects parameter 1 to be array, integer given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--int 1--
+
+Warning: array_product() expects parameter 1 to be array, integer given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--int 12345--
+
+Warning: array_product() expects parameter 1 to be array, integer given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--int -12345--
+
+Warning: array_product() expects parameter 1 to be array, integer given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--float 10.5--
+
+Warning: array_product() expects parameter 1 to be array, double given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--float -10.5--
+
+Warning: array_product() expects parameter 1 to be array, double given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--float 12.3456789000e10--
+
+Warning: array_product() expects parameter 1 to be array, double given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--float -12.3456789000e10--
+
+Warning: array_product() expects parameter 1 to be array, double given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--float .5--
+
+Warning: array_product() expects parameter 1 to be array, double given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--uppercase NULL--
+
+Warning: array_product() expects parameter 1 to be array, null given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--lowercase null--
+
+Warning: array_product() expects parameter 1 to be array, null given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--lowercase true--
+
+Warning: array_product() expects parameter 1 to be array, boolean given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--lowercase false--
+
+Warning: array_product() expects parameter 1 to be array, boolean given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--uppercase TRUE--
+
+Warning: array_product() expects parameter 1 to be array, boolean given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--uppercase FALSE--
+
+Warning: array_product() expects parameter 1 to be array, boolean given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--empty string DQ--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--empty string SQ--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--string DQ--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--string SQ--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--mixed case string--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--heredoc--
+
+Warning: array_product() expects parameter 1 to be array, Unicode string given 
in %sarray_product_variation5.php on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: array_product() expects parameter 1 to be array, object given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: array_product() expects parameter 1 to be array, object given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--undefined var--
+
+Warning: array_product() expects parameter 1 to be array, null given in 
%sarray_product_variation5.php on line %d
+NULL
+
+--unset var--
+
+Warning: array_product() expects parameter 1 to be array, null given in 
%sarray_product_variation5.php on line %d
+NULL
+===DONE===
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to