nicholsr                Fri Oct 26 11:06:31 2007 UTC

  Added files:                 
    /php-src/ext/standard/tests/array   array_splice_variation1.phpt 
                                        array_splice_variation2.phpt 
                                        array_splice_basic.phpt 
                                        array_splice_variation3.phpt 
                                        array_splice_errors.phpt 
                                        array_splice_variation4.phpt 
  Log:
  new testcases for array_splice
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_variation1.phpt
+++ php-src/ext/standard/tests/array/array_splice_variation1.phpt
--TEST--
Test array_splice() function : usage variations - references

--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 


echo "test behaviour when input array is in a reference set\n";

$input_array=array (array(1,2));
$input_array[]=&$input_array[0];
var_dump (array_splice ($input_array[0],1,1));
var_dump ($input_array);

echo "Test behaviour of input arrays containing references \n";
/*
 *  There are three regions to test:, before cut, the cut and after the cut.
 *  For reach we check a plain value, a reference value with integer key and a
 *  reference value with a string key.
 */
$numbers=array(0,1,2,3,4,5,6,7,8,9,10,11,12);
$input_array=array(0,1,&$numbers[2],"three"=>&$numbers[3],4,&$numbers[5],"six"=>&$numbers[6],7,&$numbers[8],"nine"=>&$numbers[9]);
var_dump (array_splice ($input_array,4,3));
var_dump ($input_array);

echo "Test behaviour of replacement array containing references \n";

$three=3;
$four=4;
$input_array=array (0,1,2);
$b=array(&$three,"fourkey"=>&$four);
array_splice ($input_array,-1,1,$b);
var_dump ($input_array);

echo "Test behaviour of replacement which is part of reference set \n";

$int=3;
$input_array=array (1,2);
$b=&$int;

array_splice ($input_array,-1,1,$b);
var_dump ($input_array);
echo "Done\n";
?>
--EXPECT--
test behaviour when input array is in a reference set
array(1) {
  [0]=>
  int(2)
}
array(2) {
  [0]=>
  &array(1) {
    [0]=>
    int(1)
  }
  [1]=>
  &array(1) {
    [0]=>
    int(1)
  }
}
Test behaviour of input arrays containing references 
array(3) {
  [0]=>
  int(4)
  [1]=>
  &int(5)
  ["six"]=>
  &int(6)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  &int(2)
  ["three"]=>
  &int(3)
  [3]=>
  int(7)
  [4]=>
  &int(8)
  ["nine"]=>
  &int(9)
}
Test behaviour of replacement array containing references 
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  &int(3)
  [3]=>
  &int(4)
}
Test behaviour of replacement which is part of reference set 
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(3)
}
Done
--UEXPECT--
test behaviour when input array is in a reference set
array(1) {
  [0]=>
  int(2)
}
array(2) {
  [0]=>
  &array(1) {
    [0]=>
    int(1)
  }
  [1]=>
  &array(1) {
    [0]=>
    int(1)
  }
}
Test behaviour of input arrays containing references 
array(3) {
  [0]=>
  int(4)
  [1]=>
  &int(5)
  [u"six"]=>
  &int(6)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  &int(2)
  [u"three"]=>
  &int(3)
  [3]=>
  int(7)
  [4]=>
  &int(8)
  [u"nine"]=>
  &int(9)
}
Test behaviour of replacement array containing references 
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  &int(3)
  [3]=>
  &int(4)
}
Test behaviour of replacement which is part of reference set 
array(2) {
  [0]=>
  int(1)
  [1]=>
  int(3)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_variation2.phpt
+++ php-src/ext/standard/tests/array/array_splice_variation2.phpt
--TEST--
Test array_splice() function : usage variations - additional parameters

--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 

$array=array(0,1,2);
var_dump (array_splice($array,1,1,3,4,5,6,7,8,9));
var_dump ($array);
echo "Done\n";
?>
--EXPECTF--

Warning: array_splice() expects at most 4 parameters, 10 given in %s on line %d
NULL
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
Done
--UEXPECTF--

Warning: array_splice() expects at most 4 parameters, 10 given in %s on line %d
NULL
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_basic.phpt
+++ php-src/ext/standard/tests/array/array_splice_basic.phpt
--TEST--
Test array_splice(): basic functionality
--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 

echo "*** Testing array_splice() basic operations ***\n";
echo "test truncation \n";
$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, 2));
var_dump ($input);
// $input is now array("red", "green")

echo "test removing entries from the middle \n";
$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, 1, -1));
var_dump ($input);
// $input is now array("red", "yellow")

echo "test substitution at end \n";
$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, 1, count($input), "orange"));
var_dump ($input);
// $input is now array("red", "orange")

$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, -1, 1, array("black", "maroon")));
var_dump ($input);
// $input is now array("red", "green",
//          "blue", "black", "maroon")

echo "test insertion \n";
$input = array("red", "green", "blue", "yellow");
var_dump (array_splice($input, 3, 0, "purple"));
var_dump ($input);
// $input is now array("red", "green",
//          "blue", "purple", "yellow");


?>
--EXPECT--
*** Testing array_splice() basic operations ***
test truncation 
array(2) {
  [0]=>
  string(4) "blue"
  [1]=>
  string(6) "yellow"
}
array(2) {
  [0]=>
  string(3) "red"
  [1]=>
  string(5) "green"
}
test removing entries from the middle 
array(2) {
  [0]=>
  string(5) "green"
  [1]=>
  string(4) "blue"
}
array(2) {
  [0]=>
  string(3) "red"
  [1]=>
  string(6) "yellow"
}
test substitution at end 
array(3) {
  [0]=>
  string(5) "green"
  [1]=>
  string(4) "blue"
  [2]=>
  string(6) "yellow"
}
array(2) {
  [0]=>
  string(3) "red"
  [1]=>
  string(6) "orange"
}
array(1) {
  [0]=>
  string(6) "yellow"
}
array(5) {
  [0]=>
  string(3) "red"
  [1]=>
  string(5) "green"
  [2]=>
  string(4) "blue"
  [3]=>
  string(5) "black"
  [4]=>
  string(6) "maroon"
}
test insertion 
array(0) {
}
array(5) {
  [0]=>
  string(3) "red"
  [1]=>
  string(5) "green"
  [2]=>
  string(4) "blue"
  [3]=>
  string(6) "purple"
  [4]=>
  string(6) "yellow"
}
--UEXPECT--
*** Testing array_splice() basic operations ***
test truncation 
array(2) {
  [0]=>
  unicode(4) "blue"
  [1]=>
  unicode(6) "yellow"
}
array(2) {
  [0]=>
  unicode(3) "red"
  [1]=>
  unicode(5) "green"
}
test removing entries from the middle 
array(2) {
  [0]=>
  unicode(5) "green"
  [1]=>
  unicode(4) "blue"
}
array(2) {
  [0]=>
  unicode(3) "red"
  [1]=>
  unicode(6) "yellow"
}
test substitution at end 
array(3) {
  [0]=>
  unicode(5) "green"
  [1]=>
  unicode(4) "blue"
  [2]=>
  unicode(6) "yellow"
}
array(2) {
  [0]=>
  unicode(3) "red"
  [1]=>
  unicode(6) "orange"
}
array(1) {
  [0]=>
  unicode(6) "yellow"
}
array(5) {
  [0]=>
  unicode(3) "red"
  [1]=>
  unicode(5) "green"
  [2]=>
  unicode(4) "blue"
  [3]=>
  unicode(5) "black"
  [4]=>
  unicode(6) "maroon"
}
test insertion 
array(0) {
}
array(5) {
  [0]=>
  unicode(3) "red"
  [1]=>
  unicode(5) "green"
  [2]=>
  unicode(4) "blue"
  [3]=>
  unicode(6) "purple"
  [4]=>
  unicode(6) "yellow"
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_variation3.phpt
+++ php-src/ext/standard/tests/array/array_splice_variation3.phpt
--TEST--
Test array_splice() function : usage variations - lengths and offsets

--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 

echo "*** array_splice() function : usage variations - lengths and offsets\n";


function test_splice ($offset, $length)
{
        echo "  - No replacement\n";
        $input_array=array(0,1,2,3,4,5);
        var_dump (array_splice ($input_array,$offset,$length));
        var_dump ($input_array);
    echo "  - With replacement\n";
    $input_array=array(0,1,2,3,4,5);
    var_dump (array_splice ($input_array,$offset,$length,array ("A","B","C")));
        var_dump ($input_array);
}

echo "absolute offset - absolute length - cut from beginning\n";
test_splice (0,2);
echo "absolute offset - absolute length - cut from middle\n";
test_splice (2,2);
echo "absolute offset - absolute length - cut from end\n";
test_splice (4,2);
echo "absolute offset - absolute length - attempt to cut past end\n";
test_splice (4,4);
echo "absolute offset - absolute length - cut everything\n";
test_splice (0,7);
echo "absolute offset - absolute length - cut nothing\n";
test_splice (3,0);

echo "absolute offset - relative length - cut from beginning\n";
test_splice (0,-4);

echo "absolute offset - relative length - cut from middle\n";
test_splice (2,-2);

echo "absolute offset - relative length - attempt to cut form before beginning 
\n";
test_splice (0,-7);

echo "absolute offset - relative length - cut nothing\n";
test_splice (2,-7);

echo "relative offset - absolute length - cut from beginning\n";
test_splice (-6,2);

echo "relative offset - absolute length - cut from middle\n";
test_splice (-4,2);
echo "relative offset - absolute length - cut from end\n";
test_splice (-2,2);
echo "relative offset - absolute length - attempt to cut past end\n";
test_splice (-2,4);
echo "relative offset - absolute length - cut everything\n";
test_splice (-6,6);
echo "relative offset - absolute length - cut nothing\n";
test_splice (-6,0);

echo "relative offset - relative length - cut from beginning\n";
test_splice (-6,-4);

echo "relative offset - relative length - cut from middle\n";
test_splice (-4,-2);

echo "relative offset - relative length - cut nothing\n";
test_splice (-4,-7);
echo "Done\n";
?>

--EXPECT--
*** array_splice() function : usage variations - lengths and offsets
absolute offset - absolute length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - absolute length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - absolute length - cut from end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  string(1) "A"
  [5]=>
  string(1) "B"
  [6]=>
  string(1) "C"
}
absolute offset - absolute length - attempt to cut past end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  string(1) "A"
  [5]=>
  string(1) "B"
  [6]=>
  string(1) "C"
}
absolute offset - absolute length - cut everything
  - No replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(0) {
}
  - With replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(3) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
}
absolute offset - absolute length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  string(1) "A"
  [4]=>
  string(1) "B"
  [5]=>
  string(1) "C"
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
absolute offset - relative length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - relative length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - relative length - attempt to cut form before beginning 
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(0)
  [4]=>
  int(1)
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
absolute offset - relative length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
relative offset - absolute length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - absolute length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - absolute length - cut from end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  string(1) "A"
  [5]=>
  string(1) "B"
  [6]=>
  string(1) "C"
}
relative offset - absolute length - attempt to cut past end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  string(1) "A"
  [5]=>
  string(1) "B"
  [6]=>
  string(1) "C"
}
relative offset - absolute length - cut everything
  - No replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(0) {
}
  - With replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(3) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
}
relative offset - absolute length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(0)
  [4]=>
  int(1)
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
relative offset - relative length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  string(1) "A"
  [1]=>
  string(1) "B"
  [2]=>
  string(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - relative length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - relative length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  string(1) "A"
  [3]=>
  string(1) "B"
  [4]=>
  string(1) "C"
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
Done
--UEXPECT--
*** array_splice() function : usage variations - lengths and offsets
absolute offset - absolute length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - absolute length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - absolute length - cut from end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  unicode(1) "A"
  [5]=>
  unicode(1) "B"
  [6]=>
  unicode(1) "C"
}
absolute offset - absolute length - attempt to cut past end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  unicode(1) "A"
  [5]=>
  unicode(1) "B"
  [6]=>
  unicode(1) "C"
}
absolute offset - absolute length - cut everything
  - No replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(0) {
}
  - With replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(3) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
}
absolute offset - absolute length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  unicode(1) "A"
  [4]=>
  unicode(1) "B"
  [5]=>
  unicode(1) "C"
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
absolute offset - relative length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - relative length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
absolute offset - relative length - attempt to cut form before beginning 
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(0)
  [4]=>
  int(1)
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
absolute offset - relative length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
relative offset - absolute length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - absolute length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - absolute length - cut from end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  unicode(1) "A"
  [5]=>
  unicode(1) "B"
  [6]=>
  unicode(1) "C"
}
relative offset - absolute length - attempt to cut past end
  - No replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
  - With replacement
array(2) {
  [0]=>
  int(4)
  [1]=>
  int(5)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  unicode(1) "A"
  [5]=>
  unicode(1) "B"
  [6]=>
  unicode(1) "C"
}
relative offset - absolute length - cut everything
  - No replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(0) {
}
  - With replacement
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
array(3) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
}
relative offset - absolute length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(0)
  [4]=>
  int(1)
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
relative offset - relative length - cut from beginning
  - No replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(3)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(1)
}
array(7) {
  [0]=>
  unicode(1) "A"
  [1]=>
  unicode(1) "B"
  [2]=>
  unicode(1) "C"
  [3]=>
  int(2)
  [4]=>
  int(3)
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - relative length - cut from middle
  - No replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(4)
  [3]=>
  int(5)
}
  - With replacement
array(2) {
  [0]=>
  int(2)
  [1]=>
  int(3)
}
array(7) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(4)
  [6]=>
  int(5)
}
relative offset - relative length - cut nothing
  - No replacement
array(0) {
}
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
  - With replacement
array(0) {
}
array(9) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  unicode(1) "A"
  [3]=>
  unicode(1) "B"
  [4]=>
  unicode(1) "C"
  [5]=>
  int(2)
  [6]=>
  int(3)
  [7]=>
  int(4)
  [8]=>
  int(5)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_errors.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_errors.phpt
+++ php-src/ext/standard/tests/array/array_splice_errors.phpt
--TEST--
Test  array_splice() function : error conditions
--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 

echo "\n*** Testing error conditions of array_splice() ***\n";

$int=1;
$array=array(1,2);
var_dump (array_splice());
var_dump (array_splice($int));
var_dump (array_splice($array));
var_dump (array_splice($int,$int));
$obj= new stdclass;
var_dump (array_splice($obj,0,1));
echo "Done\n";

?>
--EXPECTF--

*** Testing error conditions of array_splice() ***

Warning: array_splice() expects at least 2 parameters, 0 given in %s on line %d
NULL

Warning: array_splice() expects at least 2 parameters, 1 given in %s on line %d
NULL

Warning: array_splice() expects at least 2 parameters, 1 given in %s on line %d
NULL

Warning: array_splice() expects parameter 1 to be array, integer given in %s on 
line %d
NULL

Warning: array_splice() expects parameter 1 to be array, object given in %s on 
line %d
NULL
Done
--UEXPECTF--

*** Testing error conditions of array_splice() ***

Warning: array_splice() expects at least 2 parameters, 0 given in %s on line %d
NULL

Warning: array_splice() expects at least 2 parameters, 1 given in %s on line %d
NULL

Warning: array_splice() expects at least 2 parameters, 1 given in %s on line %d
NULL

Warning: array_splice() expects parameter 1 to be array, integer given in %s on 
line %d
NULL

Warning: array_splice() expects parameter 1 to be array, object given in %s on 
line %d
NULL
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_splice_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_splice_variation4.phpt
+++ php-src/ext/standard/tests/array/array_splice_variation4.phpt
--TEST--
Test array_splice() function : usage variations - non array replacement values

--INI--
--FILE--
<?php
/* 
 * proto array array_splice(array input, int offset [, int length [, array 
replacement]])
 * Function is implemented in ext/standard/array.c
*/ 

function test_splice ($replacement)
{
        $input_array=array(0,1);
        var_dump (array_splice ($input_array,2,0,$replacement));
        var_dump ($input_array);
}

test_splice (2);

test_splice (2.1);

test_splice (true);
//file type resource
$file_handle = fopen(__FILE__, "r");

test_splice ($file_handle);
echo "Done\n";
?>
--EXPECTF--
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  float(2.1)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  bool(true)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  resource(%d) of type (stream)
}
Done
--UEXPECTF--
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  float(2.1)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  bool(true)
}
array(0) {
}
array(3) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  resource(%d) of type (stream)
}
Done
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to