]> granicus.if.org Git - php/commitdiff
Added tests for array_shift/array_pop.
authorfoobar <sniper@php.net>
Thu, 1 Aug 2002 12:33:02 +0000 (12:33 +0000)
committerfoobar <sniper@php.net>
Thu, 1 Aug 2002 12:33:02 +0000 (12:33 +0000)
ext/standard/tests/array/005.phpt [new file with mode: 0644]
ext/standard/tests/array/006.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/005.phpt b/ext/standard/tests/array/005.phpt
new file mode 100644 (file)
index 0000000..c5636e8
--- /dev/null
@@ -0,0 +1,48 @@
+--TEST--
+Test array_shift behaviour
+--POST--
+--GET--
+--FILE--
+<?php
+
+array_shift($GLOBALS);
+
+$a = array("foo", "bar", "fubar");
+$b = array("3" => "foo", "4" => "bar", "5" => "fubar");
+$c = array("a" => "foo", "b" => "bar", "c" => "fubar");
+
+/* simple array */
+echo array_shift($a), "\n";
+var_dump($a);
+
+/* numerical assoc indices */
+echo array_shift($b), "\n";
+var_dump($b);
+
+/* assoc indices */
+echo array_shift($c), "\n";
+var_dump($c);
+
+?>
+--EXPECT--
+foo
+array(2) {
+  [0]=>
+  string(3) "bar"
+  [1]=>
+  string(5) "fubar"
+}
+foo
+array(2) {
+  [0]=>
+  string(3) "bar"
+  [1]=>
+  string(5) "fubar"
+}
+foo
+array(2) {
+  ["b"]=>
+  string(3) "bar"
+  ["c"]=>
+  string(5) "fubar"
+}
diff --git a/ext/standard/tests/array/006.phpt b/ext/standard/tests/array/006.phpt
new file mode 100644 (file)
index 0000000..9c699cd
--- /dev/null
@@ -0,0 +1,48 @@
+--TEST--
+Test array_pop behaviour
+--POST--
+--GET--
+--FILE--
+<?php
+
+array_pop($GLOBALS);
+
+$a = array("foo", "bar", "fubar");
+$b = array("3" => "foo", "4" => "bar", "5" => "fubar");
+$c = array("a" => "foo", "b" => "bar", "c" => "fubar");
+
+/* simple array */
+echo array_pop($a), "\n";
+var_dump($a);
+
+/* numerical assoc indices */
+echo array_pop($b), "\n";
+var_dump($b);
+
+/* assoc indices */
+echo array_pop($c), "\n";
+var_dump($c);
+
+?>
+--EXPECT--
+fubar
+array(2) {
+  [0]=>
+  string(3) "foo"
+  [1]=>
+  string(3) "bar"
+}
+fubar
+array(2) {
+  [3]=>
+  string(3) "foo"
+  [4]=>
+  string(3) "bar"
+}
+fubar
+array(2) {
+  ["a"]=>
+  string(3) "foo"
+  ["b"]=>
+  string(3) "bar"
+}