jmessa          Wed Feb 13 16:14:02 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/array   array_push_variation2.phpt 
                                        array_push_basic.phpt 
                                        array_push_variation1.phpt 
                                        array_push_error2.phpt 
                                        array_push_error1.phpt 
                                        array_push_variation4.phpt 
                                        array_push_variation6.phpt 
                                        array_push_variation5.phpt 
                                        array_push_variation3.phpt 
  Log:
  - New tests for array_push() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation2.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation2.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,256 @@
+--TEST--
+Test array_push() function : usage variations - Pass different data types as 
$var arg
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass different data types as $var argument to array_push to test behaviour
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+// Initialise function arguments not being substituted
+$stack = array (1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+  public function __toString() {
+    return "Class A object";
+  }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $var argument
+$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*/ "string",
+       'string',
+       $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 array_push()
+$iterator = 1;
+foreach($inputs as $input) {
+  echo "\n-- Iteration $iterator --\n";
+  $temp_array = $stack;
+  var_dump( array_push($temp_array, $input) );
+  $iterator++;
+};
+
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 --
+int(3)
+
+-- Iteration 2 --
+int(3)
+
+-- Iteration 3 --
+int(3)
+
+-- Iteration 4 --
+int(3)
+
+-- Iteration 5 --
+int(3)
+
+-- Iteration 6 --
+int(3)
+
+-- Iteration 7 --
+int(3)
+
+-- Iteration 8 --
+int(3)
+
+-- Iteration 9 --
+int(3)
+
+-- Iteration 10 --
+int(3)
+
+-- Iteration 11 --
+int(3)
+
+-- Iteration 12 --
+int(3)
+
+-- Iteration 13 --
+int(3)
+
+-- Iteration 14 --
+int(3)
+
+-- Iteration 15 --
+int(3)
+
+-- Iteration 16 --
+int(3)
+
+-- Iteration 17 --
+int(3)
+
+-- Iteration 18 --
+int(3)
+
+-- Iteration 19 --
+int(3)
+
+-- Iteration 20 --
+int(3)
+
+-- Iteration 21 --
+int(3)
+
+-- Iteration 22 --
+int(3)
+
+-- Iteration 23 --
+int(3)
+
+-- Iteration 24 --
+int(3)
+
+-- Iteration 25 --
+int(3)
+Done
+--UEXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 --
+int(3)
+
+-- Iteration 2 --
+int(3)
+
+-- Iteration 3 --
+int(3)
+
+-- Iteration 4 --
+int(3)
+
+-- Iteration 5 --
+int(3)
+
+-- Iteration 6 --
+int(3)
+
+-- Iteration 7 --
+int(3)
+
+-- Iteration 8 --
+int(3)
+
+-- Iteration 9 --
+int(3)
+
+-- Iteration 10 --
+int(3)
+
+-- Iteration 11 --
+int(3)
+
+-- Iteration 12 --
+int(3)
+
+-- Iteration 13 --
+int(3)
+
+-- Iteration 14 --
+int(3)
+
+-- Iteration 15 --
+int(3)
+
+-- Iteration 16 --
+int(3)
+
+-- Iteration 17 --
+int(3)
+
+-- Iteration 18 --
+int(3)
+
+-- Iteration 19 --
+int(3)
+
+-- Iteration 20 --
+int(3)
+
+-- Iteration 21 --
+int(3)
+
+-- Iteration 22 --
+int(3)
+
+-- Iteration 23 --
+int(3)
+
+-- Iteration 24 --
+int(3)
+
+-- Iteration 25 --
+int(3)
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_push_basic.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_basic.phpt      Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,94 @@
+--TEST--
+Test array_push() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test basic functionality of array_push with indexed and associative arrays
+ */
+
+echo "*** Testing array_push() : basic functionality ***\n";
+
+$array = array ('zero', 'one', 'two');
+$var1 = 'three';
+$var2 = 'four';
+
+echo "\n-- Push values onto an indexed array --\n";
+var_dump(array_push($array, $var1, $var2));
+var_dump($array);
+
+$array_assoc = array ('one' => 'un', 'two' => 'deux');
+
+echo "\n-- Push values onto an associative array --\n";
+var_dump(array_push($array_assoc, $var1, $var2));
+var_dump($array_assoc);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing array_push() : basic functionality ***
+
+-- Push values onto an indexed array --
+int(5)
+array(5) {
+  [0]=>
+  string(4) "zero"
+  [1]=>
+  string(3) "one"
+  [2]=>
+  string(3) "two"
+  [3]=>
+  string(5) "three"
+  [4]=>
+  string(4) "four"
+}
+
+-- Push values onto an associative array --
+int(4)
+array(4) {
+  ["one"]=>
+  string(2) "un"
+  ["two"]=>
+  string(4) "deux"
+  [0]=>
+  string(5) "three"
+  [1]=>
+  string(4) "four"
+}
+Done
+--UEXPECTF--
+*** Testing array_push() : basic functionality ***
+
+-- Push values onto an indexed array --
+int(5)
+array(5) {
+  [0]=>
+  unicode(4) "zero"
+  [1]=>
+  unicode(3) "one"
+  [2]=>
+  unicode(3) "two"
+  [3]=>
+  unicode(5) "three"
+  [4]=>
+  unicode(4) "four"
+}
+
+-- Push values onto an associative array --
+int(4)
+array(4) {
+  [u"one"]=>
+  unicode(2) "un"
+  [u"two"]=>
+  unicode(4) "deux"
+  [0]=>
+  unicode(5) "three"
+  [1]=>
+  unicode(4) "four"
+}
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation1.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation1.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,351 @@
+--TEST--
+Test array_push() function : usage variations - Pass different data types as 
$stack arg
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass different data types as $stack argument to array_push() to test 
behaviour
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+// Initialise function arguments not being substituted
+$var = 'value';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA
+{
+  public function __toString() {
+    return "Class A object";
+  }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $stack argument
+$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*/ "string",
+       'string',
+       $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 array_push()
+$iterator = 1;
+foreach($inputs as $input) {
+  echo "\n-- Iteration $iterator --\n";
+  var_dump( array_push($input, $var) );
+  $iterator++;
+};
+
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+int(1)
+
+-- Iteration 19 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 25 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+Done
+--UEXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+int(1)
+
+-- Iteration 19 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+
+-- Iteration 25 --
+
+Warning: array_push(): First argument should be an array in %s on line %d
+bool(false)
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_error2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_error2.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_push_error2.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_error2.phpt     Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,72 @@
+--TEST--
+Test array_push() function : error conditions - min and max int values as keys
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Use PHP's minimum and maximum integer values as array keys
+ * then try and push new elements onto the array
+ */
+
+echo "*** Testing array_push() : error conditions ***\n";
+
+$array = array(-PHP_INT_MAX => 'min', PHP_INT_MAX => 'max');
+
+var_dump(array_push($array, 'new'));
+var_dump($array);
+var_dump(array_push($array, 'var'));
+var_dump($array);
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing array_push() : error conditions ***
+int(3)
+array(3) {
+  [-2147483647]=>
+  string(3) "min"
+  [2147483647]=>
+  string(3) "max"
+  [-2147483648]=>
+  string(3) "new"
+}
+
+Warning: array_push(): Cannot add element to the array as the next element is 
already occupied in %s on line %d
+bool(false)
+array(3) {
+  [-2147483647]=>
+  string(3) "min"
+  [2147483647]=>
+  string(3) "max"
+  [-2147483648]=>
+  string(3) "new"
+}
+Done
+--UEXPECTF--
+*** Testing array_push() : error conditions ***
+int(3)
+array(3) {
+  [-2147483647]=>
+  unicode(3) "min"
+  [2147483647]=>
+  unicode(3) "max"
+  [-2147483648]=>
+  unicode(3) "new"
+}
+
+Warning: array_push(): Cannot add element to the array as the next element is 
already occupied in %s on line %d
+bool(false)
+array(3) {
+  [-2147483647]=>
+  unicode(3) "min"
+  [2147483647]=>
+  unicode(3) "max"
+  [-2147483648]=>
+  unicode(3) "new"
+}
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_error1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_error1.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_push_error1.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_error1.phpt     Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,38 @@
+--TEST--
+Test array_push() function : error conditions - Pass incorrect number of args
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass incorrect number of arguments to array_push() to test behaviour
+ */
+
+echo "*** Testing array_push() : error conditions ***\n";
+
+// Testing array_push with one less than the expected number of arguments
+echo "\n-- Testing array_push() function with less than expected no. of 
arguments --\n";
+$stack = array(1, 2);
+var_dump( array_push($stack) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_push() : error conditions ***
+
+-- Testing array_push() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for array_push() in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing array_push() : error conditions ***
+
+-- Testing array_push() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for array_push() in %s on line %d
+NULL
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation4.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation4.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,249 @@
+--TEST--
+Test array_push() function : usage variations - referenced variables
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test array_push when:
+ * 1. passed referenced variables as $var arguments
+ * 2. $var argument is a reference to $stack argument
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+$var1 = 'a';
+$var2 = 'b';
+$var3 = 'c';
+$var4 = 'x';
+$var5 = 'y';
+$var6 = 'z';
+
+$array = array(1, 2, 3);
+
+echo "\n-- Pass array_push referenced varialbes as \$var arguments --\n";
+
+var_dump(array_push($array, &$var1, &$var2, &$var3, &$var4, &$var5, &$var6));
+var_dump($array);
+
+echo "\n-- Pass \$var argument which is a reference to \$stack argument --\n";
+var_dump(array_push($array, &$array));
+var_dump($array);
+
+echo "Done";
+?>
+--EXPECTF--
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+*** Testing array_push() : usage variations ***
+
+-- Pass array_push referenced varialbes as $var arguments --
+int(9)
+array(9) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  &string(1) "a"
+  [4]=>
+  &string(1) "b"
+  [5]=>
+  &string(1) "c"
+  [6]=>
+  &string(1) "x"
+  [7]=>
+  &string(1) "y"
+  [8]=>
+  &string(1) "z"
+}
+
+-- Pass $var argument which is a reference to $stack argument --
+int(10)
+array(10) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  &string(1) "a"
+  [4]=>
+  &string(1) "b"
+  [5]=>
+  &string(1) "c"
+  [6]=>
+  &string(1) "x"
+  [7]=>
+  &string(1) "y"
+  [8]=>
+  &string(1) "z"
+  [9]=>
+  &array(10) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+    [3]=>
+    &string(1) "a"
+    [4]=>
+    &string(1) "b"
+    [5]=>
+    &string(1) "c"
+    [6]=>
+    &string(1) "x"
+    [7]=>
+    &string(1) "y"
+    [8]=>
+    &string(1) "z"
+    [9]=>
+    &array(10) {
+      [0]=>
+      int(1)
+      [1]=>
+      int(2)
+      [2]=>
+      int(3)
+      [3]=>
+      &string(1) "a"
+      [4]=>
+      &string(1) "b"
+      [5]=>
+      &string(1) "c"
+      [6]=>
+      &string(1) "x"
+      [7]=>
+      &string(1) "y"
+      [8]=>
+      &string(1) "z"
+      [9]=>
+      *RECURSION*
+    }
+  }
+}
+Done
+--UEXPECTF--
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+
+Strict Standards: Call-time pass-by-reference has been deprecated in %s on 
line %d
+*** Testing array_push() : usage variations ***
+
+-- Pass array_push referenced varialbes as $var arguments --
+int(9)
+array(9) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  &unicode(1) "a"
+  [4]=>
+  &unicode(1) "b"
+  [5]=>
+  &unicode(1) "c"
+  [6]=>
+  &unicode(1) "x"
+  [7]=>
+  &unicode(1) "y"
+  [8]=>
+  &unicode(1) "z"
+}
+
+-- Pass $var argument which is a reference to $stack argument --
+int(10)
+array(10) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  &unicode(1) "a"
+  [4]=>
+  &unicode(1) "b"
+  [5]=>
+  &unicode(1) "c"
+  [6]=>
+  &unicode(1) "x"
+  [7]=>
+  &unicode(1) "y"
+  [8]=>
+  &unicode(1) "z"
+  [9]=>
+  &array(10) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+    [3]=>
+    &unicode(1) "a"
+    [4]=>
+    &unicode(1) "b"
+    [5]=>
+    &unicode(1) "c"
+    [6]=>
+    &unicode(1) "x"
+    [7]=>
+    &unicode(1) "y"
+    [8]=>
+    &unicode(1) "z"
+    [9]=>
+    &array(10) {
+      [0]=>
+      int(1)
+      [1]=>
+      int(2)
+      [2]=>
+      int(3)
+      [3]=>
+      &unicode(1) "a"
+      [4]=>
+      &unicode(1) "b"
+      [5]=>
+      &unicode(1) "c"
+      [6]=>
+      &unicode(1) "x"
+      [7]=>
+      &unicode(1) "y"
+      [8]=>
+      &unicode(1) "z"
+      [9]=>
+      *RECURSION*
+    }
+  }
+}
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation6.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation6.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation6.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,211 @@
+--TEST--
+Test array_push() function : usage variations - array keys are different data 
types
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Pass array_push arrays where the keys are different data types.
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+// Initialise function arguments not being substituted
+$var = 'value';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// arrays of different data types as keys to be passed to $stack argument
+$inputs = array(
+
+       // int data
+/*1*/  'int' => array(
+       0 => 'zero',
+       1 => 'one',
+       12345 => 'positive',
+       -2345 => 'negative',
+       ),
+
+       // float data
+/*2*/  'float' => array(
+       10.5 => 'positive',
+       -10.5 => 'negative',
+       .5 => 'half',
+       ),
+       
+       'extreme floats' => array(
+       12.3456789000e10 => 'large',
+       12.3456789000E-10 => 'small',
+       ),
+
+       // null data
+/*3*/ 'null uppercase' => array(
+       NULL => 'null 1',
+       ), 
+       'null lowercase' => array(
+       null => 'null 2',
+       ),
+
+       // boolean data
+/*4*/ 'bool lowercase' => array(
+       true => 'lowert',
+       false => 'lowerf',
+       ),
+       'bool uppercase' => array(
+       TRUE => 'uppert',
+       FALSE => 'upperf',
+       ),
+       
+       // empty data
+/*5*/ 'empty double quotes' => array(
+       "" => 'emptyd',
+       ),
+       'empty single quotes' => array(
+       '' => 'emptys',
+       ),
+
+       // string data
+/*6*/ 'string' => array(
+       "stringd" => 'stringd',
+       'strings' => 'strings',
+       $heredoc => 'stringh',
+       ),
+
+       // undefined data
+/*8*/ 'undefined' => array(
+       @$undefined_var => 'undefined',
+       ),
+
+       // unset data
+/*9*/ 'unset' => array(
+       @$unset_var => 'unset',
+       ),
+);
+
+// loop through each sub-array of $inputs to check the behavior of array_push()
+$iterator = 1;
+foreach($inputs as $key => $input) {
+  echo "\n-- Iteration $iterator : $key data --\n";
+  echo "Before : ";
+  var_dump(count($input));
+  echo "After  : ";
+  var_dump( array_push($input, $var) );
+  $iterator++;
+};
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 : int data --
+Before : int(4)
+After  : int(5)
+
+-- Iteration 2 : float data --
+Before : int(3)
+After  : int(4)
+
+-- Iteration 3 : extreme floats data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 4 : null uppercase data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 5 : null lowercase data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 6 : bool lowercase data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 7 : bool uppercase data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 8 : empty double quotes data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 9 : empty single quotes data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 10 : string data --
+Before : int(3)
+After  : int(4)
+
+-- Iteration 11 : undefined data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 12 : unset data --
+Before : int(1)
+After  : int(2)
+Done
+
+--UEXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Iteration 1 : int data --
+Before : int(4)
+After  : int(5)
+
+-- Iteration 2 : float data --
+Before : int(3)
+After  : int(4)
+
+-- Iteration 3 : extreme floats data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 4 : null uppercase data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 5 : null lowercase data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 6 : bool lowercase data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 7 : bool uppercase data --
+Before : int(2)
+After  : int(3)
+
+-- Iteration 8 : empty double quotes data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 9 : empty single quotes data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 10 : string data --
+Before : int(3)
+After  : int(4)
+
+-- Iteration 11 : undefined data --
+Before : int(1)
+After  : int(2)
+
+-- Iteration 12 : unset data --
+Before : int(1)
+After  : int(2)
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation5.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation5.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation5.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,47 @@
+--TEST--
+Test array_push() function : usage variations - position of internal array 
pointer
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Check the position of the internal array pointer after calling array_push()
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+$stack = array ('one' => 'un', 'two' => 'deux');
+$var0 = 'zero';
+
+echo "\n-- Call array_push() --\n";
+var_dump($result = array_push($stack, $var0));
+
+echo "\n-- Position of Internal Pointer in Original Array: --\n";
+echo key($stack) . " => " . current ($stack) . "\n";
+
+echo "Done";
+?>
+--EXPECTF--
+
+*** Testing array_push() : usage variations ***
+
+-- Call array_push() --
+int(3)
+
+-- Position of Internal Pointer in Original Array: --
+one => un
+Done
+
+--UEXPECTF--
+
+*** Testing array_push() : usage variations ***
+
+-- Call array_push() --
+int(3)
+
+-- Position of Internal Pointer in Original Array: --
+one => un
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_push_variation3.phpt:1.2
--- /dev/null   Wed Feb 13 16:14:02 2008
+++ php-src/ext/standard/tests/array/array_push_variation3.phpt Wed Feb 13 
16:14:02 2008
@@ -0,0 +1,111 @@
+--TEST--
+Test array_push() function : usage variations - multidimensional arrays
+--FILE--
+<?php
+/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
+ * Description: Pushes elements onto the end of the array 
+ * Source code: ext/standard/array.c
+ */
+
+/*
+ * Test array_push when passed:
+ * 1. an array as $var arg
+ * 2. as sub-array as $stack arg
+ */
+
+echo "*** Testing array_push() : usage variations ***\n";
+
+echo "\n-- Pass array as \$var argument --\n";
+$array = array(1, 2, 3);
+$sub_array = array('one', 'two');
+var_dump(array_push($array, $sub_array));
+var_dump($array);
+
+echo "\n-- Pass sub-array as \$stack argument --\n";
+var_dump(array_push($array[3], 'a'));
+var_dump($array);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Pass array as $var argument --
+int(4)
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  array(2) {
+    [0]=>
+    string(3) "one"
+    [1]=>
+    string(3) "two"
+  }
+}
+
+-- Pass sub-array as $stack argument --
+int(3)
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  array(3) {
+    [0]=>
+    string(3) "one"
+    [1]=>
+    string(3) "two"
+    [2]=>
+    string(1) "a"
+  }
+}
+Done
+--UEXPECTF--
+*** Testing array_push() : usage variations ***
+
+-- Pass array as $var argument --
+int(4)
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  array(2) {
+    [0]=>
+    unicode(3) "one"
+    [1]=>
+    unicode(3) "two"
+  }
+}
+
+-- Pass sub-array as $stack argument --
+int(3)
+array(4) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+  [3]=>
+  array(3) {
+    [0]=>
+    unicode(3) "one"
+    [1]=>
+    unicode(3) "two"
+    [2]=>
+    unicode(1) "a"
+  }
+}
+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