From: Lars Strojny Date: Thu, 11 Sep 2008 18:21:24 +0000 (+0000) Subject: prev()-tests by Iain Lewis X-Git-Tag: BEFORE_HEAD_NS_CHANGE~425 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7949c4d7714f8b364b3c60ae55b99ad7740c3587;p=php prev()-tests by Iain Lewis --- diff --git a/ext/standard/tests/array/prev_basic.phpt b/ext/standard/tests/array/prev_basic.phpt new file mode 100755 index 0000000000..07a119a801 --- /dev/null +++ b/ext/standard/tests/array/prev_basic.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test prev() function : basic functionality +--FILE-- + " . current($array) . "\n"; +var_dump(prev($array)); + +echo key($array) . " => " . current($array) . "\n"; +var_dump(prev($array)); + +echo key($array) . " => " . current($array) . "\n"; +var_dump(prev($array)); + +echo "\n*** Testing an array with differing values/keys ***\n"; +$array2 = array('one', 2 => "help", 3, false, 'stringkey2' => 'val2', 'stringkey1' => 'val1'); +end($array2); +$length = count($array2); +for ($i = $length; $i > 0; $i--) { + var_dump(prev($array2)); +} + +?> +===DONE=== +--EXPECTF-- +*** Testing prev() : basic functionality *** +2 => two +unicode(3) "one" +1 => one +unicode(4) "zero" +0 => zero +bool(false) + +*** Testing an array with differing values/keys *** +unicode(4) "val2" +bool(false) +int(3) +unicode(4) "help" +unicode(3) "one" +bool(false) +===DONE=== diff --git a/ext/standard/tests/array/prev_error1.phpt b/ext/standard/tests/array/prev_error1.phpt new file mode 100755 index 0000000000..bea245196e --- /dev/null +++ b/ext/standard/tests/array/prev_error1.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test prev() function : error conditions - Pass incorrect number of arguments +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing prev() : error conditions *** + +-- Testing prev() function with Zero arguments -- + +Warning: prev() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing prev() function with more than expected no. of arguments -- + +Warning: prev() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/array/prev_error2.phpt b/ext/standard/tests/array/prev_error2.phpt new file mode 100755 index 0000000000..f26bdd0a41 --- /dev/null +++ b/ext/standard/tests/array/prev_error2.phpt @@ -0,0 +1,28 @@ +--TEST-- +prev - ensure warning is received when passing an indirect temporary. +--FILE-- + +--EXPECTF-- +-- Passing an indirect temporary variable -- + +Strict Standards: Only variables should be passed by reference in %s on line %d +int(1) diff --git a/ext/standard/tests/array/prev_error3.phpt b/ext/standard/tests/array/prev_error3.phpt new file mode 100755 index 0000000000..dfac24eacb --- /dev/null +++ b/ext/standard/tests/array/prev_error3.phpt @@ -0,0 +1,19 @@ +--TEST-- +prev - ensure we cannot pass a temporary +--FILE-- + +--EXPECTF-- + +Fatal error: Only variables can be passed by reference in %s on line %d \ No newline at end of file diff --git a/ext/standard/tests/array/prev_variation1.phpt b/ext/standard/tests/array/prev_variation1.phpt new file mode 100755 index 0000000000..43b73e850b --- /dev/null +++ b/ext/standard/tests/array/prev_variation1.phpt @@ -0,0 +1,221 @@ +--TEST-- +Test prev() function : usage variation - Pass different data types as $array_arg +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing prev() : variation *** + +-- Iteration 1 -- + +Warning: prev() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: prev() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: prev() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: prev() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: prev() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: prev() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: prev() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: prev() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: prev() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: prev() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: prev() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: prev() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: prev() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: prev() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: prev() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: prev() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: prev() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- + +Warning: prev() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: prev() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: prev() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: prev() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: prev() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: prev() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 25 -- + +Warning: prev() expects parameter 1 to be array, resource given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/array/prev_variation2.phpt b/ext/standard/tests/array/prev_variation2.phpt new file mode 100755 index 0000000000..0ce087781e --- /dev/null +++ b/ext/standard/tests/array/prev_variation2.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test prev() function : usage variation - Multi-dimensional arrays +--FILE-- + 'z'); +end($array_arg); + +echo "\n-- Pass a two-dimensional array as \$array_arg --\n"; +var_dump(prev($array_arg)); +var_dump(prev($array_arg)); + +echo "\n-- Pass a sub-array as \$array_arg --\n"; +var_dump(prev($array_arg[0])); +?> +===DONE=== +--EXPECTF-- +*** Testing prev() : usage variations *** + +-- Pass a two-dimensional array as $array_arg -- +array(3) { + [0]=> + int(9) + [1]=> + int(8) + [2]=> + int(7) +} +bool(false) + +-- Pass a sub-array as $array_arg -- +int(8) +===DONE===