mirror of
https://github.com/php/php-src.git
synced 2025-01-08 20:17:28 +08:00
MFH
This commit is contained in:
parent
4948afff78
commit
030252067e
@ -3,10 +3,6 @@ Test array_pop() function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype: mixed array_pop( array &array );
|
||||
* Description: Pops and returns the last value of the array.
|
||||
*/
|
||||
|
||||
array_pop($GLOBALS);
|
||||
|
||||
$empty_array = array();
|
||||
@ -31,24 +27,6 @@ $mixed_array = array(
|
||||
5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
|
||||
);
|
||||
|
||||
/* Testing Error Conditions */
|
||||
echo "\n*** Testing Error Conditions ***\n";
|
||||
|
||||
/* Zero argument */
|
||||
var_dump( array_pop() );
|
||||
|
||||
/* Scalar argument */
|
||||
var_dump( array_pop($number) );
|
||||
|
||||
/* String argument */
|
||||
var_dump( array_pop($str) );
|
||||
|
||||
/* Invalid Number of arguments */
|
||||
var_dump( array_pop($mixed_array[1],$mixed_array[2]) );
|
||||
|
||||
/* Empty Array as argument */
|
||||
var_dump( array_pop($empty_array) );
|
||||
|
||||
/* Loop to test normal functionality with different arrays inputs */
|
||||
echo "\n*** Normal testing with various array inputs ***\n";
|
||||
|
||||
@ -62,41 +40,9 @@ foreach( $mixed_array as $sub_array )
|
||||
$counter++;
|
||||
}
|
||||
|
||||
echo"\n*** Checking for internal array pointer being reset when pop is called ***\n";
|
||||
|
||||
echo "\nCurrent Element is : ";
|
||||
var_dump( current($mixed_array[1]) );
|
||||
|
||||
echo "\nNext Element is : ";
|
||||
var_dump( next($mixed_array[1]) );
|
||||
|
||||
echo "\nNext Element is : ";
|
||||
var_dump( next($mixed_array[1]) );
|
||||
|
||||
echo "\nPOPed Element is : ";
|
||||
var_dump( array_pop($mixed_array[1]) );
|
||||
|
||||
echo "\nCurrent Element after POP operation is: ";
|
||||
var_dump( current($mixed_array[1]) );
|
||||
|
||||
echo"\nDone";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing Error Conditions ***
|
||||
|
||||
Warning: Wrong parameter count for array_pop() in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: array_pop(): The argument should be an array in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: array_pop(): The argument should be an array in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for array_pop() in %s on line %d
|
||||
NULL
|
||||
NULL
|
||||
|
||||
*** Normal testing with various array inputs ***
|
||||
|
||||
-- Input Array for Iteration 1 is --
|
||||
@ -271,16 +217,4 @@ Array
|
||||
Output after Pop is :
|
||||
int(557)
|
||||
|
||||
*** Checking for internal array pointer being reset when pop is called ***
|
||||
|
||||
Current Element is : int(1)
|
||||
|
||||
Next Element is : int(2)
|
||||
|
||||
Next Element is : int(3)
|
||||
|
||||
POPed Element is : int(9)
|
||||
|
||||
Current Element after POP operation is: int(1)
|
||||
|
||||
Done
|
||||
|
64
ext/standard/tests/array/array_pop_errors.phpt
Normal file
64
ext/standard/tests/array/array_pop_errors.phpt
Normal file
@ -0,0 +1,64 @@
|
||||
--TEST--
|
||||
Test array_pop() function (errors)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$empty_array = array();
|
||||
$number = 5;
|
||||
$str = "abc";
|
||||
|
||||
|
||||
/* Various combinations of arrays to be used for the test */
|
||||
$mixed_array = array(
|
||||
array(),
|
||||
array( 1,2,3,4,5,6,7,8,9 ),
|
||||
array( "One", "_Two", "Three", "Four", "Five" ),
|
||||
array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ),
|
||||
array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ),
|
||||
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
|
||||
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
|
||||
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF",
|
||||
"blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
|
||||
array( 12, "name", 'age', '45' ),
|
||||
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
|
||||
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
|
||||
5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
|
||||
);
|
||||
|
||||
/* Testing Error Conditions */
|
||||
echo "\n*** Testing Error Conditions ***\n";
|
||||
|
||||
/* Zero argument */
|
||||
var_dump( array_pop() );
|
||||
|
||||
/* Scalar argument */
|
||||
var_dump( array_pop($number) );
|
||||
|
||||
/* String argument */
|
||||
var_dump( array_pop($str) );
|
||||
|
||||
/* Invalid Number of arguments */
|
||||
var_dump( array_pop($mixed_array[1],$mixed_array[2]) );
|
||||
|
||||
/* Empty Array as argument */
|
||||
var_dump( array_pop($empty_array) );
|
||||
|
||||
echo"\nDone";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing Error Conditions ***
|
||||
|
||||
Warning: Wrong parameter count for array_pop() in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: array_pop(): The argument should be an array in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: array_pop(): The argument should be an array in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for array_pop() in %s on line %d
|
||||
NULL
|
||||
NULL
|
||||
|
||||
Done
|
55
ext/standard/tests/array/array_pop_variation.phpt
Normal file
55
ext/standard/tests/array/array_pop_variation.phpt
Normal file
@ -0,0 +1,55 @@
|
||||
--TEST--
|
||||
Test array_pop() function (variation)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Various combinations of arrays to be used for the test */
|
||||
$mixed_array = array(
|
||||
array(),
|
||||
array( 1,2,3,4,5,6,7,8,9 ),
|
||||
array( "One", "_Two", "Three", "Four", "Five" ),
|
||||
array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ),
|
||||
array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ),
|
||||
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
|
||||
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
|
||||
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF",
|
||||
"blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
|
||||
array( 12, "name", 'age', '45' ),
|
||||
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
|
||||
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
|
||||
5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
|
||||
);
|
||||
|
||||
echo"\n*** Checking for internal array pointer being reset when pop is called ***\n";
|
||||
|
||||
echo "\nCurrent Element is : ";
|
||||
var_dump( current($mixed_array[1]) );
|
||||
|
||||
echo "\nNext Element is : ";
|
||||
var_dump( next($mixed_array[1]) );
|
||||
|
||||
echo "\nNext Element is : ";
|
||||
var_dump( next($mixed_array[1]) );
|
||||
|
||||
echo "\nPOPed Element is : ";
|
||||
var_dump( array_pop($mixed_array[1]) );
|
||||
|
||||
echo "\nCurrent Element after POP operation is: ";
|
||||
var_dump( current($mixed_array[1]) );
|
||||
|
||||
echo"\nDone";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Checking for internal array pointer being reset when pop is called ***
|
||||
|
||||
Current Element is : int(1)
|
||||
|
||||
Next Element is : int(2)
|
||||
|
||||
Next Element is : int(3)
|
||||
|
||||
POPed Element is : int(9)
|
||||
|
||||
Current Element after POP operation is: int(1)
|
||||
|
||||
Done
|
@ -2,15 +2,8 @@
|
||||
Test range() function
|
||||
--INI--
|
||||
precision=14
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype: array range ( mixed $low, mixed $high [, number $step] );
|
||||
Description: Create an array containing a range of elements
|
||||
*/
|
||||
|
||||
echo "*** Testing range() function on basic operations ***\n";
|
||||
|
||||
@ -53,62 +46,7 @@ var_dump( range("1", "2", 0.1) );
|
||||
echo "\n-- Testing basic string with step --\n";
|
||||
var_dump( range("abcd", "mnop", 2) );
|
||||
|
||||
echo "\n*** Testing range() with various low and high values ***";
|
||||
$low_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
|
||||
$high_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
|
||||
|
||||
for( $i = 0; $i < count($low_arr); $i++) {
|
||||
for( $j = 0; $j < count($high_arr); $j++) {
|
||||
echo "\n-- creating an array with low = '$low_arr[$i]' and high = '$high_arr[$j]' --\n";
|
||||
var_dump( range( $low_arr[$i], $high_arr[$j] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "\n*** Possible variatins with steps ***\n";
|
||||
var_dump( range( 1, 5, TRUE ) );
|
||||
var_dump( range( 1, 5, array(1, 2) ) );
|
||||
|
||||
echo "\n*** Testing max/outof range values ***\n";
|
||||
/*var_dump( range("a", "z", 255) );
|
||||
var_dump( range("z", "a", 255) ); */
|
||||
var_dump( range(2147483645, 2147483646) );
|
||||
var_dump( range(2147483646, 2147483648) );
|
||||
var_dump( range(-2147483647, -2147483646) );
|
||||
var_dump( range(-2147483648, -2147483647) );
|
||||
var_dump( range(-2147483649, -2147483647) );
|
||||
|
||||
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 "\nDone";
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing range() function on basic operations ***
|
||||
@ -507,701 +445,4 @@ array(7) {
|
||||
[6]=>
|
||||
string(1) "m"
|
||||
}
|
||||
|
||||
*** Testing range() with various low and high values ***
|
||||
-- creating an array with low = 'ABCD' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "A"
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = 'ABCD' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '-10.5555' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '1' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
[11]=>
|
||||
float(0.4445)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = 'Array' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
[11]=>
|
||||
float(0.4445)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = 'ABCD' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '-10.5555' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(1)
|
||||
[1]=>
|
||||
float(0)
|
||||
[2]=>
|
||||
float(-1)
|
||||
[3]=>
|
||||
float(-2)
|
||||
[4]=>
|
||||
float(-3)
|
||||
[5]=>
|
||||
float(-4)
|
||||
[6]=>
|
||||
float(-5)
|
||||
[7]=>
|
||||
float(-6)
|
||||
[8]=>
|
||||
float(-7)
|
||||
[9]=>
|
||||
float(-8)
|
||||
[10]=>
|
||||
float(-9)
|
||||
[11]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '1' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = 'Array' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = 'ABCD' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '-10.5555' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(1)
|
||||
[1]=>
|
||||
float(0)
|
||||
[2]=>
|
||||
float(-1)
|
||||
[3]=>
|
||||
float(-2)
|
||||
[4]=>
|
||||
float(-3)
|
||||
[5]=>
|
||||
float(-4)
|
||||
[6]=>
|
||||
float(-5)
|
||||
[7]=>
|
||||
float(-6)
|
||||
[8]=>
|
||||
float(-7)
|
||||
[9]=>
|
||||
float(-8)
|
||||
[10]=>
|
||||
float(-9)
|
||||
[11]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '1' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = 'Array' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
*** Possible variatins with steps ***
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
}
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
}
|
||||
|
||||
*** Testing max/outof range values ***
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(2147483645)
|
||||
[1]=>
|
||||
int(2147483646)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(2147483646)
|
||||
[1]=>
|
||||
float(2147483647)
|
||||
[2]=>
|
||||
float(2147483648)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(-2147483647)
|
||||
[1]=>
|
||||
int(-2147483646)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
float(-2147483648)
|
||||
[1]=>
|
||||
float(-2147483647)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(-2147483649)
|
||||
[1]=>
|
||||
float(-2147483648)
|
||||
[2]=>
|
||||
float(-2147483647)
|
||||
}
|
||||
|
||||
*** 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
|
||||
|
File diff suppressed because it is too large
Load Diff
99
ext/standard/tests/array/range_errors.phpt
Normal file
99
ext/standard/tests/array/range_errors.phpt
Normal file
@ -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
|
626
ext/standard/tests/array/range_variation.phpt
Normal file
626
ext/standard/tests/array/range_variation.phpt
Normal file
@ -0,0 +1,626 @@
|
||||
--TEST--
|
||||
Test range() function (variation-1)
|
||||
--INI--
|
||||
precision=14
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "\n*** Testing range() with various low and high values ***";
|
||||
$low_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
|
||||
$high_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
|
||||
|
||||
for( $i = 0; $i < count($low_arr); $i++) {
|
||||
for( $j = 0; $j < count($high_arr); $j++) {
|
||||
echo "\n-- creating an array with low = '$low_arr[$i]' and high = '$high_arr[$j]' --\n";
|
||||
var_dump( range( $low_arr[$i], $high_arr[$j] ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n*** Possible variatins with steps ***\n";
|
||||
var_dump( range( 1, 5, TRUE ) );
|
||||
var_dump( range( 1, 5, array(1, 2) ) );
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing range() with various low and high values ***
|
||||
-- creating an array with low = 'ABCD' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "A"
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'ABCD' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = 'ABCD' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '-10.5555' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '1' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
[11]=>
|
||||
float(0.4445)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = '' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
}
|
||||
|
||||
-- creating an array with low = '-10.5555' and high = 'Array' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(-10.5555)
|
||||
[1]=>
|
||||
float(-9.5555)
|
||||
[2]=>
|
||||
float(-8.5555)
|
||||
[3]=>
|
||||
float(-7.5555)
|
||||
[4]=>
|
||||
float(-6.5555)
|
||||
[5]=>
|
||||
float(-5.5555)
|
||||
[6]=>
|
||||
float(-4.5555)
|
||||
[7]=>
|
||||
float(-3.5555)
|
||||
[8]=>
|
||||
float(-2.5555)
|
||||
[9]=>
|
||||
float(-1.5555)
|
||||
[10]=>
|
||||
float(-0.5555)
|
||||
[11]=>
|
||||
float(0.4445)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = 'ABCD' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '-10.5555' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(1)
|
||||
[1]=>
|
||||
float(0)
|
||||
[2]=>
|
||||
float(-1)
|
||||
[3]=>
|
||||
float(-2)
|
||||
[4]=>
|
||||
float(-3)
|
||||
[5]=>
|
||||
float(-4)
|
||||
[6]=>
|
||||
float(-5)
|
||||
[7]=>
|
||||
float(-6)
|
||||
[8]=>
|
||||
float(-7)
|
||||
[9]=>
|
||||
float(-8)
|
||||
[10]=>
|
||||
float(-9)
|
||||
[11]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '1' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '1' and high = 'Array' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'ABCD' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '-10.5555' --
|
||||
array(11) {
|
||||
[0]=>
|
||||
float(0)
|
||||
[1]=>
|
||||
float(-1)
|
||||
[2]=>
|
||||
float(-2)
|
||||
[3]=>
|
||||
float(-3)
|
||||
[4]=>
|
||||
float(-4)
|
||||
[5]=>
|
||||
float(-5)
|
||||
[6]=>
|
||||
float(-6)
|
||||
[7]=>
|
||||
float(-7)
|
||||
[8]=>
|
||||
float(-8)
|
||||
[9]=>
|
||||
float(-9)
|
||||
[10]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '1' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = '' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = '' and high = 'Array' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = 'ABCD' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '-10.5555' --
|
||||
array(12) {
|
||||
[0]=>
|
||||
float(1)
|
||||
[1]=>
|
||||
float(0)
|
||||
[2]=>
|
||||
float(-1)
|
||||
[3]=>
|
||||
float(-2)
|
||||
[4]=>
|
||||
float(-3)
|
||||
[5]=>
|
||||
float(-4)
|
||||
[6]=>
|
||||
float(-5)
|
||||
[7]=>
|
||||
float(-6)
|
||||
[8]=>
|
||||
float(-7)
|
||||
[9]=>
|
||||
float(-8)
|
||||
[10]=>
|
||||
float(-9)
|
||||
[11]=>
|
||||
float(-10)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '1' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = '' --
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
|
||||
-- creating an array with low = 'Array' and high = 'Array' --
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
*** Possible variatins with steps ***
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
}
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
}
|
||||
Done
|
60
ext/standard/tests/array/range_variation1.phpt
Normal file
60
ext/standard/tests/array/range_variation1.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Test range() function (variation-2)
|
||||
--INI--
|
||||
precision=14
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "\n*** Testing max/outof range values ***\n";
|
||||
/*var_dump( range("a", "z", 255) );
|
||||
var_dump( range("z", "a", 255) ); */
|
||||
var_dump( range(2147483645, 2147483646) );
|
||||
var_dump( range(2147483646, 2147483648) );
|
||||
var_dump( range(-2147483647, -2147483646) );
|
||||
var_dump( range(-2147483648, -2147483647) );
|
||||
var_dump( range(-2147483649, -2147483647) );
|
||||
|
||||
echo "\nDone";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing max/outof range values ***
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(2147483645)
|
||||
[1]=>
|
||||
int(2147483646)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(2147483646)
|
||||
[1]=>
|
||||
float(2147483647)
|
||||
[2]=>
|
||||
float(2147483648)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(-2147483647)
|
||||
[1]=>
|
||||
int(-2147483646)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
float(-2147483648)
|
||||
[1]=>
|
||||
float(-2147483647)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(-2147483649)
|
||||
[1]=>
|
||||
float(-2147483648)
|
||||
[2]=>
|
||||
float(-2147483647)
|
||||
}
|
||||
|
||||
Done
|
60
ext/standard/tests/array/range_variation1_64bit.phpt
Normal file
60
ext/standard/tests/array/range_variation1_64bit.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Test range() function (variation-2)
|
||||
--INI--
|
||||
precision=14
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "\n*** Testing max/outof range values ***\n";
|
||||
/*var_dump( range("a", "z", 255) );
|
||||
var_dump( range("z", "a", 255) ); */
|
||||
var_dump( range(2147483645, 2147483646) );
|
||||
var_dump( range(2147483646, 2147483648) );
|
||||
var_dump( range(-2147483647, -2147483646) );
|
||||
var_dump( range(-2147483648, -2147483647) );
|
||||
var_dump( range(-2147483649, -2147483647) );
|
||||
|
||||
echo "\nDone";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing max/outof range values ***
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(2147483645)
|
||||
[1]=>
|
||||
int(2147483646)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2147483646)
|
||||
[1]=>
|
||||
int(2147483647)
|
||||
[2]=>
|
||||
int(2147483648)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(-2147483647)
|
||||
[1]=>
|
||||
int(-2147483646)
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(-2147483648)
|
||||
[1]=>
|
||||
int(-2147483647)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(-2147483649)
|
||||
[1]=>
|
||||
int(-2147483648)
|
||||
[2]=>
|
||||
int(-2147483647)
|
||||
}
|
||||
|
||||
Done
|
Loading…
Reference in New Issue
Block a user