diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
commit | 10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch) | |
tree | 3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/standard/tests/array | |
parent | 0e920280a2e04b110827bb766b9f29e3d581c4ee (diff) | |
download | php-10f5b47dc7c1cf2b9a00991629f43652710322d3.tar.gz |
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/standard/tests/array')
-rwxr-xr-x | ext/standard/tests/array/bug29253.phpt | 13 | ||||
-rw-r--r-- | ext/standard/tests/array/bug30833.phpt | 35 | ||||
-rwxr-xr-x | ext/standard/tests/array/bug31158.phpt | 17 | ||||
-rw-r--r-- | ext/standard/tests/array/bug31213.phpt | 2 | ||||
-rwxr-xr-x | ext/standard/tests/array/bug33940.phpt | 62 | ||||
-rwxr-xr-x | ext/standard/tests/array/bug33989.phpt | 10 | ||||
-rwxr-xr-x | ext/standard/tests/array/bug34227.phpt | 100 |
7 files changed, 239 insertions, 0 deletions
diff --git a/ext/standard/tests/array/bug29253.phpt b/ext/standard/tests/array/bug29253.phpt new file mode 100755 index 000000000..7d6cdaeb4 --- /dev/null +++ b/ext/standard/tests/array/bug29253.phpt @@ -0,0 +1,13 @@ +--TEST--
+Bug #29253 array_diff with $GLOBALS argument fails
+--FILE--
+<?php
+$zz = $GLOBALS;
+$gg = 'afad';
+var_dump(array_diff_assoc($GLOBALS, $zz));
+var_dump($gg);
+?>
+--EXPECT--
+array(0) {
+}
+string(4) "afad"
diff --git a/ext/standard/tests/array/bug30833.phpt b/ext/standard/tests/array/bug30833.phpt new file mode 100644 index 000000000..61701a532 --- /dev/null +++ b/ext/standard/tests/array/bug30833.phpt @@ -0,0 +1,35 @@ +--TEST-- +bug #30833 (array_count_values() modifying input array) +--FILE-- +<?php + +$foo = array('abc', '0000'); +var_dump($foo); + +$count = array_count_values( $foo ); +var_dump($count); + +var_dump($foo); + +echo "Done\n"; +?> +--EXPECT-- +array(2) { + [0]=> + string(3) "abc" + [1]=> + string(4) "0000" +} +array(2) { + ["abc"]=> + int(1) + [0]=> + int(1) +} +array(2) { + [0]=> + string(3) "abc" + [1]=> + string(4) "0000" +} +Done diff --git a/ext/standard/tests/array/bug31158.phpt b/ext/standard/tests/array/bug31158.phpt new file mode 100755 index 000000000..e672a10b2 --- /dev/null +++ b/ext/standard/tests/array/bug31158.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #31158 (array_splice on $GLOBALS crashes) +--FILE-- +<?php +function __(){ + $GLOBALS['a'] = "bug\n"; + array_splice($GLOBALS,0,count($GLOBALS)); + /* All global variables including $GLOBALS are removed */ + echo $GLOBALS['a']; +} +__(); +echo "ok\n"; +?> +--EXPECTF-- +Notice: Undefined variable: GLOBALS in %sbug31158.php on line 6 +ok + diff --git a/ext/standard/tests/array/bug31213.phpt b/ext/standard/tests/array/bug31213.phpt index 55ad88110..6aa31d5e0 100644 --- a/ext/standard/tests/array/bug31213.phpt +++ b/ext/standard/tests/array/bug31213.phpt @@ -28,6 +28,8 @@ function test($use_extract) { test(false); test(true); + +?> --EXPECT-- int(1) int(1) diff --git a/ext/standard/tests/array/bug33940.phpt b/ext/standard/tests/array/bug33940.phpt new file mode 100755 index 000000000..e5c499001 --- /dev/null +++ b/ext/standard/tests/array/bug33940.phpt @@ -0,0 +1,62 @@ +--TEST--
+Bug #33940 array_map() fails to pass by reference when called recursively
+--INI--
+error_reporting=4095
+--FILE--
+<?php
+function ref_map(&$item) {
+ if(!is_array($item)) {
+ $item = 1;
+ return 2;
+ } else {
+ $ret = array_map('ref_map', &$item);
+ return $ret;
+ }
+}
+
+$a = array(array(0), 0);
+$ret = array_map('ref_map', $a);
+echo 'Array: '; print_r($a);
+echo 'Return: '; print_r($ret);
+$a = array(array(0), 0);
+$ret = array_map('ref_map', &$a);
+echo 'Array: '; print_r($a);
+echo 'Return: '; print_r($ret);
+?>
+--EXPECT--
+Array: Array
+(
+ [0] => Array
+ (
+ [0] => 0
+ )
+
+ [1] => 0
+)
+Return: Array
+(
+ [0] => Array
+ (
+ [0] => 2
+ )
+
+ [1] => 2
+)
+Array: Array
+(
+ [0] => Array
+ (
+ [0] => 1
+ )
+
+ [1] => 1
+)
+Return: Array
+(
+ [0] => Array
+ (
+ [0] => 2
+ )
+
+ [1] => 2
+)
diff --git a/ext/standard/tests/array/bug33989.phpt b/ext/standard/tests/array/bug33989.phpt new file mode 100755 index 000000000..4bb9a2562 --- /dev/null +++ b/ext/standard/tests/array/bug33989.phpt @@ -0,0 +1,10 @@ +--TEST--
+Bug #33989 (extract($GLOBALS,EXTR_REFS) crashes PHP)
+--FILE--
+<?php
+$a="a";
+extract($GLOBALS, EXTR_REFS);
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/ext/standard/tests/array/bug34227.phpt b/ext/standard/tests/array/bug34227.phpt new file mode 100755 index 000000000..29762b723 --- /dev/null +++ b/ext/standard/tests/array/bug34227.phpt @@ -0,0 +1,100 @@ +--TEST-- +Bug #34277 (array_filter() crashes with references and objects) +--FILE-- +<?php + +class C +{ + function m1() + { + $this->m2(); + } + + function m2() + { + $this->m3(); + } + + function m3() + { + $this->m4(); + } + + function m4() + { + $this->m5(); + } + + function m5() + { + $this->m6(); + } + + function m6() + { + $this->m7(); + } + + function m7() + { + $this->m8(); + } + + function m8() + { + $this->m9(); + } + + function m9() + { + $this->m10(); + } + + function m10() + { + $this->m11(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } + + function m11($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10) + { + $arr = explode('a', 'b'); + } +} + +function f($str) +{ + $obj = new C; + $obj->m1(); + return TRUE; +} + +function p5($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12) +{ + $ret = array_filter(array(0), 'f'); +} + +function p4() +{ + p5(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); +} + +function p3() +{ + p4(); +} + +function p2() +{ + p3(); +} + +function p1() +{ + p2(); +} + +p1(); +echo "ok\n"; +?> +--EXPECT-- +ok |