jmessa Wed Feb 13 14:19:37 2008 UTC
Added files:
/php-src/ext/standard/tests/array array_merge_variation1.phpt
array_merge_variation5.phpt
array_merge_variation2.phpt
array_merge_variation9.phpt
array_merge_basic.phpt
array_merge_variation8.phpt
array_merge_variation4.phpt
array_merge_variation7.phpt
array_merge_variation6.phpt
array_merge_variation3.phpt
array_merge_error.phpt
array_merge_variation10.phpt
Log:
- committing tests for array_merge() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation1.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation1.phpt
--TEST--
Test array_merge() function : usage variations - Pass different data types to
$arr1 arg
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass different data types as $arr1 argument to test behaviour
*/
echo "*** Testing array_merge() : usage variations ***\n";
// Initialise function arguments not being substituted
$arr2 = 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 $arr1 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_merge()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( array_merge($input, $arr2) );
$iterator++;
};
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 18 --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 19 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 24 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 25 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 18 --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 19 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 24 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
-- Iteration 25 --
Warning: array_merge(): Argument #1 is not an array in %s on line %d
NULL
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation5.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation5.phpt
--TEST--
Test array_merge() function : usage variations - numeric keys
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass array_merge() arrays with only numeric keys to test behaviour.
* $arr2 contains a duplicate element to $arr1.
*/
echo "*** Testing array_merge() : usage variations ***\n";
//numeric keys
$arr1 = array('zero', 'one', 'two', 'three');
$arr2 = array(1 => 'one', 20 => 'twenty', 30 => 'thirty');
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
array(7) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(5) "three"
[4]=>
string(3) "one"
[5]=>
string(6) "twenty"
[6]=>
string(6) "thirty"
}
array(7) {
[0]=>
string(3) "one"
[1]=>
string(6) "twenty"
[2]=>
string(6) "thirty"
[3]=>
string(4) "zero"
[4]=>
string(3) "one"
[5]=>
string(3) "two"
[6]=>
string(5) "three"
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
array(7) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(3) "two"
[3]=>
unicode(5) "three"
[4]=>
unicode(3) "one"
[5]=>
unicode(6) "twenty"
[6]=>
unicode(6) "thirty"
}
array(7) {
[0]=>
unicode(3) "one"
[1]=>
unicode(6) "twenty"
[2]=>
unicode(6) "thirty"
[3]=>
unicode(4) "zero"
[4]=>
unicode(3) "one"
[5]=>
unicode(3) "two"
[6]=>
unicode(5) "three"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation2.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation2.phpt
--TEST--
Test array_merge() function : usage variations - Pass different data types as
$arr2 arg
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass different data types as $arr2 argument to array_merge() to test
behaviour
*/
echo "*** Testing array_merge() : usage variations ***\n";
// Initialise function arguments not being substituted
$arr1 = 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 $arr2 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_merge()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( array_merge($arr1, $input) );
$iterator++;
};
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 18 --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 19 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 24 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 25 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 2 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 3 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 4 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 5 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 6 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 7 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 8 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 9 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 10 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 11 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 12 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 13 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 14 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 15 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 16 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 17 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 18 --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 19 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 20 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 21 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 22 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 23 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 24 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
-- Iteration 25 --
Warning: array_merge(): Argument #2 is not an array in %s on line %d
NULL
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation9.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation9.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation9.phpt
--TEST--
Test array_merge() function : usage variations - referenced variables
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/* Test array_merge() when:
* 1. Passed an array made up of referenced variables
* 2. Passed an array as the first argument and a reference to that array as
the second.
*/
echo "*** Testing array_merge() : usage variations ***\n";
$val1 = 'foo';
$val2 = 'bar';
$val3 = 'baz';
$arr1 = array(&$val1, &$val2, &$val3);
$arr2 = array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3');
echo "\n-- Merge an array made up of referenced variables to an assoc. array
--\n";
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
$val2 = 'hello world';
echo "\n-- Change \$val2 --\n";
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
echo "\n-- Merge an array and a reference to the first array --\n";
var_dump(array_merge($arr2, &$arr2));
echo "Done";
?>
--EXPECTF--
Strict Standards: Call-time pass-by-reference has been deprecated in %s on line
%d
*** Testing array_merge() : usage variations ***
-- Merge an array made up of referenced variables to an assoc. array --
array(6) {
[0]=>
&string(3) "foo"
[1]=>
&string(3) "bar"
[2]=>
&string(3) "baz"
["key1"]=>
string(4) "val1"
["key2"]=>
string(4) "val2"
["key3"]=>
string(4) "val3"
}
array(6) {
["key1"]=>
string(4) "val1"
["key2"]=>
string(4) "val2"
["key3"]=>
string(4) "val3"
[0]=>
&string(3) "foo"
[1]=>
&string(3) "bar"
[2]=>
&string(3) "baz"
}
-- Change $val2 --
array(6) {
[0]=>
&string(3) "foo"
[1]=>
&string(11) "hello world"
[2]=>
&string(3) "baz"
["key1"]=>
string(4) "val1"
["key2"]=>
string(4) "val2"
["key3"]=>
string(4) "val3"
}
array(6) {
["key1"]=>
string(4) "val1"
["key2"]=>
string(4) "val2"
["key3"]=>
string(4) "val3"
[0]=>
&string(3) "foo"
[1]=>
&string(11) "hello world"
[2]=>
&string(3) "baz"
}
-- Merge an array and a reference to the first array --
array(3) {
["key1"]=>
string(4) "val1"
["key2"]=>
string(4) "val2"
["key3"]=>
string(4) "val3"
}
Done
--UEXPECTF--
Strict Standards: Call-time pass-by-reference has been deprecated in %s on line
%d
*** Testing array_merge() : usage variations ***
-- Merge an array made up of referenced variables to an assoc. array --
array(6) {
[0]=>
&unicode(3) "foo"
[1]=>
&unicode(3) "bar"
[2]=>
&unicode(3) "baz"
[u"key1"]=>
unicode(4) "val1"
[u"key2"]=>
unicode(4) "val2"
[u"key3"]=>
unicode(4) "val3"
}
array(6) {
[u"key1"]=>
unicode(4) "val1"
[u"key2"]=>
unicode(4) "val2"
[u"key3"]=>
unicode(4) "val3"
[0]=>
&unicode(3) "foo"
[1]=>
&unicode(3) "bar"
[2]=>
&unicode(3) "baz"
}
-- Change $val2 --
array(6) {
[0]=>
&unicode(3) "foo"
[1]=>
&unicode(11) "hello world"
[2]=>
&unicode(3) "baz"
[u"key1"]=>
unicode(4) "val1"
[u"key2"]=>
unicode(4) "val2"
[u"key3"]=>
unicode(4) "val3"
}
array(6) {
[u"key1"]=>
unicode(4) "val1"
[u"key2"]=>
unicode(4) "val2"
[u"key3"]=>
unicode(4) "val3"
[0]=>
&unicode(3) "foo"
[1]=>
&unicode(11) "hello world"
[2]=>
&unicode(3) "baz"
}
-- Merge an array and a reference to the first array --
array(3) {
[u"key1"]=>
unicode(4) "val1"
[u"key2"]=>
unicode(4) "val2"
[u"key3"]=>
unicode(4) "val3"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_basic.phpt
+++ php-src/ext/standard/tests/array/array_merge_basic.phpt
--TEST--
Test array_merge() function : basic functionality
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Test basic functionality of array_merge()
*/
echo "*** Testing array_merge() : basic functionality ***\n";
//indexed array
$array1 = array ('zero', 'one', 'two');
//associative array
$array2 = array ('a' => 1, 'b' => 2, 'c' => 3);
var_dump(array_merge($array1, $array2));
var_dump(array_merge($array2, $array1));
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : basic functionality ***
array(6) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
["a"]=>
int(1)
["b"]=>
int(2)
["c"]=>
int(3)
}
array(6) {
["a"]=>
int(1)
["b"]=>
int(2)
["c"]=>
int(3)
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
}
Done
--UEXPECTF--
*** Testing array_merge() : basic functionality ***
array(6) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(3) "two"
[u"a"]=>
int(1)
[u"b"]=>
int(2)
[u"c"]=>
int(3)
}
array(6) {
[u"a"]=>
int(1)
[u"b"]=>
int(2)
[u"c"]=>
int(3)
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(3) "two"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation8.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation8.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation8.phpt
--TEST--
Test array_merge() function : usage variations - multi-dimensional arrays
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Test array_merge() with multi-dimensional arrays
*/
echo "*** Testing array_merge() : usage variations ***\n";
$arr1 = array('zero', 'one', 'two', array(0));
$arr2 = array(1, 2, 3);
echo "\n-- Merge a two-dimensional and a one-dimensional array --\n";
var_dump(array_merge($arr1, $arr2));
echo "\n-- Merge an array and a sub-array --\n";
var_dump(array_merge($arr1[3], $arr2));
var_dump(array_merge($arr2, $arr1[3]));
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Merge a two-dimensional and a one-dimensional array --
array(7) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
array(1) {
[0]=>
int(0)
}
[4]=>
int(1)
[5]=>
int(2)
[6]=>
int(3)
}
-- Merge an array and a sub-array --
array(4) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(3)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(0)
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Merge a two-dimensional and a one-dimensional array --
array(7) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(3) "two"
[3]=>
array(1) {
[0]=>
int(0)
}
[4]=>
int(1)
[5]=>
int(2)
[6]=>
int(3)
}
-- Merge an array and a sub-array --
array(4) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(3)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(0)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation4.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation4.phpt
--TEST--
Test array_merge() function : usage variations - Diff. data types as array keys
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass an array with different data types as keys to test how array_merge
* adds it onto an existing array
*/
echo "*** Testing array_merge() : usage variations ***\n";
// Initialise function arguments not being substituted
$arr = array ('one' => 1, 'two' => 2);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// arrays with keys as different data types to be passed as $input
$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',
),
/*3*/ 'extreme floats' => array(
12.3456789000e10 => 'large',
12.3456789000E-10 => 'small',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
),
// string data
/*10*/ 'string' => array(
"stringd" => 'stringd',
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_merge
$iterator = 1;
foreach($inputs as $key => $input) {
echo "\n-- Iteration $iterator: $key data --\n";
var_dump( array_merge($input, $arr) );
var_dump( array_merge($arr, $input) );
$iterator++;
};
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1: int data --
array(6) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(8) "positive"
[3]=>
string(8) "negative"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(6) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(8) "positive"
[3]=>
string(8) "negative"
}
-- Iteration 2: float data --
array(5) {
[0]=>
string(8) "positive"
[1]=>
string(8) "negative"
[2]=>
string(4) "half"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(5) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(8) "positive"
[1]=>
string(8) "negative"
[2]=>
string(4) "half"
}
-- Iteration 3: extreme floats data --
array(4) {
[0]=>
string(5) "large"
[1]=>
string(5) "small"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(4) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(5) "large"
[1]=>
string(5) "small"
}
-- Iteration 4: null uppercase data --
array(3) {
[""]=>
string(6) "null 1"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "null 1"
}
-- Iteration 5: null lowercase data --
array(3) {
[""]=>
string(6) "null 2"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "null 2"
}
-- Iteration 6: bool lowercase data --
array(4) {
[0]=>
string(6) "lowert"
[1]=>
string(6) "lowerf"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(4) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(6) "lowert"
[1]=>
string(6) "lowerf"
}
-- Iteration 7: bool uppercase data --
array(4) {
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(4) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
}
-- Iteration 8: empty double quotes data --
array(3) {
[""]=>
string(6) "emptyd"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "emptyd"
}
-- Iteration 9: empty single quotes data --
array(3) {
[""]=>
string(6) "emptys"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "emptys"
}
-- Iteration 10: string data --
array(5) {
["stringd"]=>
string(7) "stringd"
["strings"]=>
string(7) "strings"
["hello world"]=>
string(7) "stringh"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(5) {
["one"]=>
int(1)
["two"]=>
int(2)
["stringd"]=>
string(7) "stringd"
["strings"]=>
string(7) "strings"
["hello world"]=>
string(7) "stringh"
}
-- Iteration 11: undefined data --
array(3) {
[""]=>
string(9) "undefined"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(9) "undefined"
}
-- Iteration 12: unset data --
array(3) {
[""]=>
string(5) "unset"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(5) "unset"
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1: int data --
array(6) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(8) "positive"
[3]=>
unicode(8) "negative"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(6) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(8) "positive"
[3]=>
unicode(8) "negative"
}
-- Iteration 2: float data --
array(5) {
[0]=>
unicode(8) "positive"
[1]=>
unicode(8) "negative"
[2]=>
unicode(4) "half"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(5) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[0]=>
unicode(8) "positive"
[1]=>
unicode(8) "negative"
[2]=>
unicode(4) "half"
}
-- Iteration 3: extreme floats data --
array(4) {
[0]=>
unicode(5) "large"
[1]=>
unicode(5) "small"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(4) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[0]=>
unicode(5) "large"
[1]=>
unicode(5) "small"
}
-- Iteration 4: null uppercase data --
array(3) {
[u""]=>
unicode(6) "null 1"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(6) "null 1"
}
-- Iteration 5: null lowercase data --
array(3) {
[u""]=>
unicode(6) "null 2"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(6) "null 2"
}
-- Iteration 6: bool lowercase data --
array(4) {
[0]=>
unicode(6) "lowert"
[1]=>
unicode(6) "lowerf"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(4) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[0]=>
unicode(6) "lowert"
[1]=>
unicode(6) "lowerf"
}
-- Iteration 7: bool uppercase data --
array(4) {
[0]=>
unicode(6) "uppert"
[1]=>
unicode(6) "upperf"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(4) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[0]=>
unicode(6) "uppert"
[1]=>
unicode(6) "upperf"
}
-- Iteration 8: empty double quotes data --
array(3) {
[u""]=>
unicode(6) "emptyd"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(6) "emptyd"
}
-- Iteration 9: empty single quotes data --
array(3) {
[u""]=>
unicode(6) "emptys"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(6) "emptys"
}
-- Iteration 10: string data --
array(5) {
[u"stringd"]=>
unicode(7) "stringd"
[u"strings"]=>
unicode(7) "strings"
[u"hello world"]=>
unicode(7) "stringh"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(5) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u"stringd"]=>
unicode(7) "stringd"
[u"strings"]=>
unicode(7) "strings"
[u"hello world"]=>
unicode(7) "stringh"
}
-- Iteration 11: undefined data --
array(3) {
[u""]=>
unicode(9) "undefined"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(9) "undefined"
}
-- Iteration 12: unset data --
array(3) {
[u""]=>
unicode(5) "unset"
[u"one"]=>
int(1)
[u"two"]=>
int(2)
}
array(3) {
[u"one"]=>
int(1)
[u"two"]=>
int(2)
[u""]=>
unicode(5) "unset"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation7.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation7.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation7.phpt
--TEST--
Test array_merge() function : usage variations - Mixed keys
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass array_merge() arrays with mixed keys to test how it attaches them to
* existing arrays
*/
echo "*** Testing array_merge() : usage variations ***\n";
//mixed keys
$arr1 = array('zero', 20 => 'twenty', 'thirty' => 30, true => 'bool');
$arr2 = array(0, 1, 2, null => 'null', 1.234E-10 => 'float');
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
array(8) {
[0]=>
string(4) "zero"
[1]=>
string(6) "twenty"
["thirty"]=>
int(30)
[2]=>
string(4) "bool"
[3]=>
string(5) "float"
[4]=>
int(1)
[5]=>
int(2)
[""]=>
string(4) "null"
}
array(8) {
[0]=>
string(5) "float"
[1]=>
int(1)
[2]=>
int(2)
[""]=>
string(4) "null"
[3]=>
string(4) "zero"
[4]=>
string(6) "twenty"
["thirty"]=>
int(30)
[5]=>
string(4) "bool"
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
array(8) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(6) "twenty"
[u"thirty"]=>
int(30)
[2]=>
unicode(4) "bool"
[3]=>
unicode(5) "float"
[4]=>
int(1)
[5]=>
int(2)
[u""]=>
unicode(4) "null"
}
array(8) {
[0]=>
unicode(5) "float"
[1]=>
int(1)
[2]=>
int(2)
[u""]=>
unicode(4) "null"
[3]=>
unicode(4) "zero"
[4]=>
unicode(6) "twenty"
[u"thirty"]=>
int(30)
[5]=>
unicode(4) "bool"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation6.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation6.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation6.phpt
--TEST--
Test array_merge() function : usage variations - string keys
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass array_merge arrays with string keys to test behaviour.
* $arr2 has a duplicate key to $arr1
*/
echo "*** Testing array_merge() : usage variations ***\n";
//string keys
$arr1 = array('zero' => 'zero', 'one' => 'un', 'two' => 'deux');
$arr2 = array('zero' => 'zero', 'un' => 'eins', 'deux' => 'zwei');
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
array(5) {
["zero"]=>
string(4) "zero"
["one"]=>
string(2) "un"
["two"]=>
string(4) "deux"
["un"]=>
string(4) "eins"
["deux"]=>
string(4) "zwei"
}
array(5) {
["zero"]=>
string(4) "zero"
["un"]=>
string(4) "eins"
["deux"]=>
string(4) "zwei"
["one"]=>
string(2) "un"
["two"]=>
string(4) "deux"
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
array(5) {
[u"zero"]=>
unicode(4) "zero"
[u"one"]=>
unicode(2) "un"
[u"two"]=>
unicode(4) "deux"
[u"un"]=>
unicode(4) "eins"
[u"deux"]=>
unicode(4) "zwei"
}
array(5) {
[u"zero"]=>
unicode(4) "zero"
[u"un"]=>
unicode(4) "eins"
[u"deux"]=>
unicode(4) "zwei"
[u"one"]=>
unicode(2) "un"
[u"two"]=>
unicode(4) "deux"
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation3.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation3.phpt
--TEST--
Test array_merge() function : usage variations - arrays of diff. data types
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass arrays of different data types to test how array_merge adds them
* onto an existing array
*/
echo "*** Testing array_merge() : usage variations ***\n";
// Initialise function arguments not being substituted
$arr = 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");
// arrays of different data types to be passed as $input
$inputs = array(
// int data
/*1*/ 'int' => array(
0,
1,
12345,
-2345,
),
// float data
/*2*/ 'float' => array(
10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
),
// null data
/*3*/ 'null' => array(
NULL,
null,
),
// boolean data
/*4*/ 'bool' => array(
true,
false,
TRUE,
FALSE,
),
// empty data
/*5*/ 'empty string' => array(
"",
'',
),
/*6*/ 'empty array' => array(
),
// string data
/*7*/ 'string' => array(
"string",
'string',
$heredoc,
),
// object data
/*8*/ 'object' => array(
new classA(),
),
// undefined data
/*9*/ 'undefined' => array(
@$undefined_var,
),
// unset data
/*10*/ 'unset' => array(
@$unset_var,
),
// resource variable
/*11*/ 'resource' => array(
$fp
),
);
// loop through each element of $inputs to check the behavior of array_merge
$iterator = 1;
foreach($inputs as $key => $input) {
echo "\n-- Iteration $iterator: $key data --\n";
var_dump( array_merge($input, $arr) );
var_dump( array_merge($arr, $input) );
$iterator++;
};
fclose($fp);
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1: int data --
array(6) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(12345)
[3]=>
int(-2345)
[4]=>
int(1)
[5]=>
int(2)
}
array(6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(0)
[3]=>
int(1)
[4]=>
int(12345)
[5]=>
int(-2345)
}
-- Iteration 2: float data --
array(7) {
[0]=>
float(10.5)
[1]=>
float(-10.5)
[2]=>
float(123456789000)
[3]=>
float(1.23456789E-9)
[4]=>
float(0.5)
[5]=>
int(1)
[6]=>
int(2)
}
array(7) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
float(10.5)
[3]=>
float(-10.5)
[4]=>
float(123456789000)
[5]=>
float(1.23456789E-9)
[6]=>
float(0.5)
}
-- Iteration 3: null data --
array(4) {
[0]=>
NULL
[1]=>
NULL
[2]=>
int(1)
[3]=>
int(2)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
[3]=>
NULL
}
-- Iteration 4: bool data --
array(6) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(false)
[4]=>
int(1)
[5]=>
int(2)
}
array(6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
bool(true)
[3]=>
bool(false)
[4]=>
bool(true)
[5]=>
bool(false)
}
-- Iteration 5: empty string data --
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
int(1)
[3]=>
int(2)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
string(0) ""
[3]=>
string(0) ""
}
-- Iteration 6: empty array data --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 7: string data --
array(5) {
[0]=>
string(6) "string"
[1]=>
string(6) "string"
[2]=>
string(11) "hello world"
[3]=>
int(1)
[4]=>
int(2)
}
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
string(6) "string"
[3]=>
string(6) "string"
[4]=>
string(11) "hello world"
}
-- Iteration 8: object data --
array(3) {
[0]=>
object(classA)#%d (0) {
}
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
object(classA)#%d (0) {
}
}
-- Iteration 9: undefined data --
array(3) {
[0]=>
NULL
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
}
-- Iteration 10: unset data --
array(3) {
[0]=>
NULL
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
}
-- Iteration 11: resource data --
array(3) {
[0]=>
resource(%d) of type (stream)
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
resource(%d) of type (stream)
}
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Iteration 1: int data --
array(6) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(12345)
[3]=>
int(-2345)
[4]=>
int(1)
[5]=>
int(2)
}
array(6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(0)
[3]=>
int(1)
[4]=>
int(12345)
[5]=>
int(-2345)
}
-- Iteration 2: float data --
array(7) {
[0]=>
float(10.5)
[1]=>
float(-10.5)
[2]=>
float(123456789000)
[3]=>
float(1.23456789E-9)
[4]=>
float(0.5)
[5]=>
int(1)
[6]=>
int(2)
}
array(7) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
float(10.5)
[3]=>
float(-10.5)
[4]=>
float(123456789000)
[5]=>
float(1.23456789E-9)
[6]=>
float(0.5)
}
-- Iteration 3: null data --
array(4) {
[0]=>
NULL
[1]=>
NULL
[2]=>
int(1)
[3]=>
int(2)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
[3]=>
NULL
}
-- Iteration 4: bool data --
array(6) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(false)
[4]=>
int(1)
[5]=>
int(2)
}
array(6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
bool(true)
[3]=>
bool(false)
[4]=>
bool(true)
[5]=>
bool(false)
}
-- Iteration 5: empty string data --
array(4) {
[0]=>
unicode(0) ""
[1]=>
unicode(0) ""
[2]=>
int(1)
[3]=>
int(2)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
unicode(0) ""
[3]=>
unicode(0) ""
}
-- Iteration 6: empty array data --
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
-- Iteration 7: string data --
array(5) {
[0]=>
unicode(6) "string"
[1]=>
unicode(6) "string"
[2]=>
unicode(11) "hello world"
[3]=>
int(1)
[4]=>
int(2)
}
array(5) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
unicode(6) "string"
[3]=>
unicode(6) "string"
[4]=>
unicode(11) "hello world"
}
-- Iteration 8: object data --
array(3) {
[0]=>
object(classA)#%d (0) {
}
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
object(classA)#%d (0) {
}
}
-- Iteration 9: undefined data --
array(3) {
[0]=>
NULL
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
}
-- Iteration 10: unset data --
array(3) {
[0]=>
NULL
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
NULL
}
-- Iteration 11: resource data --
array(3) {
[0]=>
resource(%d) of type (stream)
[1]=>
int(1)
[2]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
resource(%d) of type (stream)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_error.phpt
+++ php-src/ext/standard/tests/array/array_merge_error.phpt
--TEST--
Test array_merge() function : error conditions - Pass incorrect number of args
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Pass incorrect number of arguments to array_merge() to test behaviour
*/
echo "*** Testing array_merge() : error conditions ***\n";
// Testing array_merge with zero arguments
echo "\n-- Testing array_merge() function with less than expected no. of
arguments --\n";
$arr1 = array(1, 2);
var_dump( array_merge() );
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : error conditions ***
-- Testing array_merge() function with less than expected no. of arguments --
Warning: Wrong parameter count for array_merge() in %s on line %d
NULL
Done
--UEXPECTF--
*** Testing array_merge() : error conditions ***
-- Testing array_merge() function with less than expected no. of arguments --
Warning: Wrong parameter count for array_merge() in %s on line %d
NULL
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_merge_variation10.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_merge_variation10.phpt
+++ php-src/ext/standard/tests/array/array_merge_variation10.phpt
--TEST--
Test array_merge() function : usage variations - position of internal array
pointer
--FILE--
<?php
/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
* Description: Merges elements from passed arrays into one array
* Source code: ext/standard/array.c
*/
/*
* Check the position of the internal array pointer after calling array_merge().
* This test is also passing more than two arguments to array_merge().
*/
echo "*** Testing array_merge() : usage variations ***\n";
$arr1 = array ('zero', 'one', 'two');
$arr2 = array ('zero', 'un', 'deux');
$arr3 = array ('null', 'eins', 'zwei');
echo "\n-- Call array_merge() --\n";
var_dump($result = array_merge($arr1, $arr2, $arr3));
echo "\n-- Position of Internal Pointer in Result: --\n";
echo key($result) . " => " . current($result) . "\n";
echo "\n-- Position of Internal Pointer in Original Array: --\n";
echo "\$arr1: ";
echo key($arr1) . " => " . current ($arr1) . "\n";
echo "\$arr2: ";
echo key($arr2) . " => " . current ($arr2) . "\n";
echo "\$arr3: ";
echo key($arr3) . " => " . current ($arr3) . "\n";
echo "Done";
?>
--EXPECTF--
*** Testing array_merge() : usage variations ***
-- Call array_merge() --
array(9) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(4) "zero"
[4]=>
string(2) "un"
[5]=>
string(4) "deux"
[6]=>
string(4) "null"
[7]=>
string(4) "eins"
[8]=>
string(4) "zwei"
}
-- Position of Internal Pointer in Result: --
0 => zero
-- Position of Internal Pointer in Original Array: --
$arr1: 0 => zero
$arr2: 0 => zero
$arr3: 0 => null
Done
--UEXPECTF--
*** Testing array_merge() : usage variations ***
-- Call array_merge() --
array(9) {
[0]=>
unicode(4) "zero"
[1]=>
unicode(3) "one"
[2]=>
unicode(3) "two"
[3]=>
unicode(4) "zero"
[4]=>
unicode(2) "un"
[5]=>
unicode(4) "deux"
[6]=>
unicode(4) "null"
[7]=>
unicode(4) "eins"
[8]=>
unicode(4) "zwei"
}
-- Position of Internal Pointer in Result: --
0 => zero
-- Position of Internal Pointer in Original Array: --
$arr1: 0 => zero
$arr2: 0 => zero
$arr3: 0 => null
Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php