summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/range_errors.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/array/range_errors.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/array/range_errors.phpt')
-rw-r--r--ext/standard/tests/array/range_errors.phpt99
1 files changed, 99 insertions, 0 deletions
diff --git a/ext/standard/tests/array/range_errors.phpt b/ext/standard/tests/array/range_errors.phpt
new file mode 100644
index 0000000..9652e28
--- /dev/null
+++ b/ext/standard/tests/array/range_errors.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Test range() function (errors)
+--INI--
+precision=14
+--FILE--
+<?php
+
+echo "\n*** Testing error conditions ***\n";
+
+echo "\n-- Testing ( (low < high) && (step = 0) ) --";
+var_dump( range(1, 2, 0) );
+var_dump( range("a", "b", 0) );
+
+echo "\n\n-- Testing ( (low > high) && (step = 0) ) --";
+var_dump( range(2, 1, 0) );
+var_dump( range("b", "a", 0) );
+
+echo "\n\n-- Testing ( (low < high) && (high-low < step) ) --";
+var_dump( range(1.0, 7.0, 6.5) );
+
+echo "\n\n-- Testing ( (low > high) && (low-high < step) ) --";
+var_dump( range(7.0, 1.0, 6.5) );
+
+echo "\n-- Testing Invalid number of arguments --";
+var_dump( range() ); // No.of args = 0
+var_dump( range(1) ); // No.of args < expected
+var_dump( range(1,2,3,4) ); // No.of args > expected
+var_dump( range(-1, -2, 2) );
+var_dump( range("a", "j", "z") );
+
+echo "\n-- Testing Invalid steps --";
+$step_arr = array( "string", NULL, FALSE, "", "\0" );
+
+foreach( $step_arr as $step ) {
+ var_dump( range( 1, 5, $step ) );
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing ( (low < high) && (step = 0) ) --
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+
+-- Testing ( (low > high) && (step = 0) ) --
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+
+-- Testing ( (low < high) && (high-low < step) ) --
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+
+-- Testing ( (low > high) && (low-high < step) ) --
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+-- Testing Invalid number of arguments --
+Warning: range() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: range() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: range() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+-- Testing Invalid steps --
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+
+Warning: range(): step exceeds the specified range in %s on line %d
+bool(false)
+Done