From: Robert Nicholson Date: Fri, 26 Oct 2007 11:06:31 +0000 (+0000) Subject: new testcases for array_splice X-Git-Tag: RELEASE_2_0_0a1~1541 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94c63b3442a29f7067736b494242f3ebf681a39f;p=php new testcases for array_splice --- diff --git a/ext/standard/tests/array/array_splice_basic.phpt b/ext/standard/tests/array/array_splice_basic.phpt new file mode 100644 index 0000000000..ae1fae6afb --- /dev/null +++ b/ext/standard/tests/array/array_splice_basic.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test array_splice(): basic functionality +--INI-- +--FILE-- + +--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" +} diff --git a/ext/standard/tests/array/array_splice_errors.phpt b/ext/standard/tests/array/array_splice_errors.phpt new file mode 100644 index 0000000000..a7268a911a --- /dev/null +++ b/ext/standard/tests/array/array_splice_errors.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test array_splice() function : error conditions +--INI-- +--FILE-- + +--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 \ No newline at end of file diff --git a/ext/standard/tests/array/array_splice_variation1.phpt b/ext/standard/tests/array/array_splice_variation1.phpt new file mode 100644 index 0000000000..a9b7d8d429 --- /dev/null +++ b/ext/standard/tests/array/array_splice_variation1.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test array_splice() function : usage variations - references + +--INI-- +--FILE-- +&$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 \ No newline at end of file diff --git a/ext/standard/tests/array/array_splice_variation2.phpt b/ext/standard/tests/array/array_splice_variation2.phpt new file mode 100644 index 0000000000..454a3d38ca --- /dev/null +++ b/ext/standard/tests/array/array_splice_variation2.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test array_splice() function : usage variations - additional parameters + +--INI-- +--FILE-- + +--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 \ No newline at end of file diff --git a/ext/standard/tests/array/array_splice_variation3.phpt b/ext/standard/tests/array/array_splice_variation3.phpt new file mode 100644 index 0000000000..07f1d0c286 --- /dev/null +++ b/ext/standard/tests/array/array_splice_variation3.phpt @@ -0,0 +1,1640 @@ +--TEST-- +Test array_splice() function : usage variations - lengths and offsets + +--INI-- +--FILE-- + + +--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 \ No newline at end of file diff --git a/ext/standard/tests/array/array_splice_variation4.phpt b/ext/standard/tests/array/array_splice_variation4.phpt new file mode 100644 index 0000000000..2e0b94bdeb --- /dev/null +++ b/ext/standard/tests/array/array_splice_variation4.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test array_splice() function : usage variations - non array replacement values + +--INI-- +--FILE-- + +--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 \ No newline at end of file