Browse Source

add 64bit tests

experimental/5.2-WITH_DRCP
Antony Dovgal 19 years ago
parent
commit
9100e9efde
  1. 472
      ext/standard/tests/array/array_keys_64bit.phpt
  2. BIN
      ext/standard/tests/array/array_values_64bit.phpt
  3. 238
      ext/standard/tests/array/end_64bit.phpt
  4. BIN
      ext/standard/tests/general_functions/debug_zval_dump_b_64bit.phpt
  5. 443
      ext/standard/tests/general_functions/is_float_64bit.phpt
  6. 468
      ext/standard/tests/general_functions/is_int_64bit.phpt
  7. 1740
      ext/standard/tests/general_functions/print_r_64bit.phpt
  8. 1913
      ext/standard/tests/general_functions/var_dump_64bit.phpt

472
ext/standard/tests/array/array_keys_64bit.phpt

@ -0,0 +1,472 @@
--TEST--
Test array_keys() function
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--INI--
precision=14
--FILE--
<?php
/*
Prototype: array array_keys( array $input [, mixed $search_value [,
bool $strict]]);
Description: Return all the keys of an array
*/
echo "*** Testing array_keys() on basic array operation ***\n";
$basic_arr = array("a" => 1, "b" => 2, 2.0 => 2.0, -23.45 => "asdasd",
array(1,2,3));
var_dump(array_keys($basic_arr));
echo "\n*** Testing array_keys() on various arrays ***";
$arrays = array(
array(),
array(0),
array( array() ),
array("Hello" => "World"),
array("" => ""),
array(1,2,3, "d" => array(4,6, "d")),
array("a" => 1, "b" => 2, "c" =>3, "d" => array()),
array(0 => 0, 1 => 1, 2 => 2, 3 => 3),
array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000),
array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"),
array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ),
array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" )
);
$i = 0;
/* loop through to test array_keys() with different arrays */
foreach ($arrays as $array) {
echo "\n-- Iteration $i --\n";
var_dump(array_keys($array));
$i++;
}
echo "\n*** Testing array_keys() on all the types other than arrays ***";
$types_arr = array(
TRUE => TRUE,
FALSE => FALSE,
1 => 1,
0 => 0,
-1 => -1,
"1" => "1",
"0" => "0",
"-1" => "-1",
NULL,
array(),
"php" => "php",
"" => ""
);
$values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", "");
foreach ($values as $value){
echo "\n-- Loose type checking --\n";
var_dump(array_keys($types_arr, $value));
echo "\n-- strict type checking --\n";
var_dump(array_keys($types_arr, $value, TRUE));
}
echo "\n*** Testing array_keys() with resource type ***\n";
$resource1 = fopen( __FILE__, "r");
$resource2 = opendir( "." );
/* creating an array with resource types as elements */
$arr_resource = array($resource1, $resource2);
var_dump(array_keys($arr_resource, $resource1)); // loose type checking
var_dump(array_keys($arr_resource, $resource1, TRUE)); // strict type checking
var_dump(array_keys($arr_resource, $resource2)); // loose type checking
var_dump(array_keys($arr_resource, $resource2, TRUE)); // strict type checking
echo "\n*** Testing array_keys() on range of values ***\n";
$arr_range = array(
2147483647 => 1,
2147483648 => 2,
-2147483647 => 3,
-2147483648 => 4,
-2147483649 => 5,
-0 => 6,
0 => 7
);
var_dump(array_keys($arr_range));
echo "\n*** Testing array_keys() on an array created on the fly ***\n";
var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3)));
var_dump(array_keys(array())); // null array
echo "\n*** Testing error conditions ***";
var_dump(array_keys(100));
var_dump(array_keys("string"));
var_dump(array_keys(new stdclass)); // object
var_dump(array_keys()); // Zero arguments
var_dump(array_keys(array(), "", TRUE, 100)); // args > expected
var_dump(array_keys(array(1,2,3, array() => array()))); // (W)illegal offset
echo "Done\n";
--CLEAN--
/* Closing the resource handles */
fclose( $resource1 );
closedir( $resource2 );
?>
--EXPECTF--
*** Testing array_keys() on basic array operation ***
array(5) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
int(2)
[3]=>
int(-23)
[4]=>
int(3)
}
*** Testing array_keys() on various arrays ***
-- Iteration 0 --
array(0) {
}
-- Iteration 1 --
array(1) {
[0]=>
int(0)
}
-- Iteration 2 --
array(1) {
[0]=>
int(0)
}
-- Iteration 3 --
array(1) {
[0]=>
string(5) "Hello"
}
-- Iteration 4 --
array(1) {
[0]=>
string(0) ""
}
-- Iteration 5 --
array(4) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
string(1) "d"
}
-- Iteration 6 --
array(4) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
[3]=>
string(1) "d"
}
-- Iteration 7 --
array(4) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(3)
}
-- Iteration 8 --
array(5) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
string(1) "a"
[3]=>
int(3)
[4]=>
int(5)
}
-- Iteration 9 --
array(5) {
[0]=>
int(1)
[1]=>
int(0)
[2]=>
string(0) ""
[3]=>
int(2)
[4]=>
int(3)
}
-- Iteration 10 --
array(3) {
[0]=>
string(1) "a"
[1]=>
string(2) "ab"
[2]=>
string(2) "cd"
}
-- Iteration 11 --
array(4) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
string(0) ""
}
*** Testing array_keys() on all the types other than arrays ***
-- Loose type checking --
array(3) {
[0]=>
int(1)
[1]=>
int(-1)
[2]=>
string(3) "php"
}
-- strict type checking --
array(0) {
}
-- Loose type checking --
array(4) {
[0]=>
int(0)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
string(0) ""
}
-- strict type checking --
array(0) {
}
-- Loose type checking --
array(1) {
[0]=>
int(1)
}
-- strict type checking --
array(0) {
}
-- Loose type checking --
array(4) {
[0]=>
int(0)
[1]=>
int(2)
[2]=>
string(3) "php"
[3]=>
string(0) ""
}
-- strict type checking --
array(0) {
}
-- Loose type checking --
array(1) {
[0]=>
int(-1)
}
-- strict type checking --
array(0) {
}
-- Loose type checking --
array(1) {
[0]=>
int(1)
}
-- strict type checking --
array(1) {
[0]=>
int(1)
}
-- Loose type checking --
array(1) {
[0]=>
int(0)
}
-- strict type checking --
array(1) {
[0]=>
int(0)
}
-- Loose type checking --
array(1) {
[0]=>
int(-1)
}
-- strict type checking --
array(1) {
[0]=>
int(-1)
}
-- Loose type checking --
array(3) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
string(0) ""
}
-- strict type checking --
array(1) {
[0]=>
int(2)
}
-- Loose type checking --
array(2) {
[0]=>
int(2)
[1]=>
int(3)
}
-- strict type checking --
array(1) {
[0]=>
int(3)
}
-- Loose type checking --
array(1) {
[0]=>
string(3) "php"
}
-- strict type checking --
array(1) {
[0]=>
string(3) "php"
}
-- Loose type checking --
array(2) {
[0]=>
int(2)
[1]=>
string(0) ""
}
-- strict type checking --
array(1) {
[0]=>
string(0) ""
}
*** Testing array_keys() with resource type ***
array(1) {
[0]=>
int(0)
}
array(1) {
[0]=>
int(0)
}
array(1) {
[0]=>
int(1)
}
array(1) {
[0]=>
int(1)
}
*** Testing array_keys() on range of values ***
array(6) {
[0]=>
int(2147483647)
[1]=>
int(2147483648)
[2]=>
int(-2147483647)
[3]=>
int(-2147483648)
[4]=>
int(-2147483649)
[5]=>
int(0)
}
*** Testing array_keys() on an array created on the fly ***
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
array(0) {
}
*** Testing error conditions ***
Warning: array_keys(): The first argument should be an array in %s on line %d
NULL
Warning: array_keys(): The first argument should be an array in %s on line %d
NULL
Warning: array_keys(): The first argument should be an array in %s on line %d
NULL
Warning: Wrong parameter count for array_keys() in %s on line %d
NULL
Warning: Wrong parameter count for array_keys() in %s on line %d
NULL
Warning: Illegal offset type in %s on line %d
array(3) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
}
Done

BIN
ext/standard/tests/array/array_values_64bit.phpt

238
ext/standard/tests/array/end_64bit.phpt

@ -0,0 +1,238 @@
--TEST--
Test end() function
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--INI--
precision=14
--FILE--
<?php
/* Prototype: mixed end ( array &$array );
Description: Advances internal pointer of array to last element, and returns its value.
*/
$arrays = array (
array( 0 ),
range(1, 100 ),
range('a', 'z', 2 ),
array("a" => "A", 2 => "B", "C" => 3, 4 => 4, "one" => 1, "" => NULL ),
array(1, array(1, 2 => 3 ), "one" => 1, "5" => 5 ),
array(-1, -2, -3, -4, "-0.005" => "neg0.005", 2.0 => "float2", "neg.9" => -.9 ),
array(1.0005, 2.000000, -3.000000, -4.9999999 ),
array(true, false),
array("PHP", "Web2.0", "SOA"),
array(1, array() ),
array(1, 2, "" ),
array(" "),
array(2147483647, 2147483648, -2147483647, -2147483648 ),
array(0x7FFFFFFF, -0x80000000, 017777777777, -020000000000 ),
array(-.6700000E+3, -4.10003E+3, 1e-5, -1E+5, 000002.00 )
);
/* loop through $arrays to print the last element of each sub-array */
echo "*** Testing end() on different arrays ***\n";
$counter = 1;
foreach ($arrays as $sub_array){
echo "-- Iteration $counter --\n";
var_dump( end($sub_array) );
/* ensure that internal pointer is moved to last element */
var_dump( current($sub_array) );
$counter++;
}
/* checking for end() on sub-arrays */
echo "\n*** Testing end() with sub-arrays ***\n";
$test_array = array(1, array(1 => "one", "two" => 2, "" => "f") );
var_dump( end($test_array) );
var_dump( end($test_array[1]) );
/* checking working of end() when array elements are deleted */
echo "\n*** Testing end() when array elements are deleted ***\n";
$array_test = array("a", "b", "d", 7, "u" => "U", -4, "-.008" => "neg.008");
// remove first element from array
echo "\n-- Remove first element from array --\n";
unset($array_test[0]);
var_dump( end($array_test) );
// remove last element from array, rewind and check end()
echo "\n-- Remove last element from array --\n";
unset($array_test['-.008']);
var_dump( end($array_test) );
reset( $array_test );
var_dump( end($array_test) );
// remove any element !first, !last, rewind and check end()
echo "\n-- Remove any element from array apart from first and last element --\n";
unset($array_test[7]);
var_dump( end($array_test) );
var_dump( reset($array_test) );
var_dump( end($array_test) );
/* Checking on OBJECTS type */
echo "\n*** Testing end() on objects ***\n";
class foo
{
function __toString() {
return "Object";
}
}
class foo1
{
function __toString() {
return "Object1";
}
}
$object1 = new foo(); //new object created
$object2 = new foo1();
$array_object = array();
$array_object[0] = &$object1;
$array_object[1] = &$object2;
var_dump( end($array_object) );
var_dump($array_object);
/* Checking on RESOURCE type */
echo "\n*** Testing end() on resource type ***\n";
//file type resource
$file_handle = fopen(__FILE__, "r");
//directory type resource
$dir_handle = opendir( dirname(__FILE__) );
//store resources in array
$resources = array($file_handle, $dir_handle);
var_dump( end($resources) );
var_dump( current($resources) );
echo "\n*** Testing error conditions ***\n";
/* checking for unexpected number of arguments */
var_dump( end() );
var_dump( end($array[0], $array[0]) );
/* checking for unexpected type of arguments */
$var=1;
$var1="string";
var_dump( end($var) );
var_dump( end($var1) );
/* checking null array */
$null_array = array();
var_dump( end($null_array) );
echo "Done\n";
?>
--CLEAN--
/* cleaning resource handles */
fclose( $file_handle ); //file resource handle deleted
closedir( $dir_handle ); //dir resource handle deleted
--EXPECTF--
*** Testing end() on different arrays ***
-- Iteration 1 --
int(0)
int(0)
-- Iteration 2 --
int(100)
int(100)
-- Iteration 3 --
string(1) "y"
string(1) "y"
-- Iteration 4 --
NULL
NULL
-- Iteration 5 --
int(5)
int(5)
-- Iteration 6 --
float(-0.9)
float(-0.9)
-- Iteration 7 --
float(-4.9999999)
float(-4.9999999)
-- Iteration 8 --
bool(false)
bool(false)
-- Iteration 9 --
string(3) "SOA"
string(3) "SOA"
-- Iteration 10 --
array(0) {
}
array(0) {
}
-- Iteration 11 --
string(0) ""
string(0) ""
-- Iteration 12 --
string(1) " "
string(1) " "
-- Iteration 13 --
int(-2147483648)
int(-2147483648)
-- Iteration 14 --
int(-2147483648)
int(-2147483648)
-- Iteration 15 --
float(2)
float(2)
*** Testing end() with sub-arrays ***
array(3) {
[1]=>
string(3) "one"
["two"]=>
int(2)
[""]=>
string(1) "f"
}
string(1) "f"
*** Testing end() when array elements are deleted ***
-- Remove first element from array --
string(7) "neg.008"
-- Remove last element from array --
int(-4)
int(-4)
-- Remove any element from array apart from first and last element --
int(-4)
string(1) "b"
int(-4)
*** Testing end() on objects ***
object(foo1)#2 (0) {
}
array(2) {
[0]=>
&object(foo)#1 (0) {
}
[1]=>
&object(foo1)#2 (0) {
}
}
*** Testing end() on resource type ***
resource(6) of type (stream)
resource(6) of type (stream)
*** Testing error conditions ***
Warning: Wrong parameter count for end() in /home/tony/php-src_5_2/ext/standard/tests/array/end_64bit.php on line 102
NULL
Warning: Wrong parameter count for end() in /home/tony/php-src_5_2/ext/standard/tests/array/end_64bit.php on line 103
NULL
Warning: end(): Passed variable is not an array or object in /home/tony/php-src_5_2/ext/standard/tests/array/end_64bit.php on line 108
bool(false)
Warning: end(): Passed variable is not an array or object in /home/tony/php-src_5_2/ext/standard/tests/array/end_64bit.php on line 109
bool(false)
bool(false)
Done

BIN
ext/standard/tests/general_functions/debug_zval_dump_b_64bit.phpt

443
ext/standard/tests/general_functions/is_float_64bit.phpt

@ -0,0 +1,443 @@
--TEST--
Test is_float() & it's FALIASes: is_double() & is_real() functions
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--INI--
precision=14
--FILE--
<?php
/* Prototype: bool is_float ( mixed $var );
* Description: Finds whether the given variable is a float
*/
echo "*** Testing is_float(), is_double() and is_real() with float values***\n";
// different valid float vlaues
$floats = array(
-2147483649, // float value
2147483648, // float value
-0x80000001, // float value, beyond max negative int
0x800000001, // float value, beyond max positive int
020000000001, // float value, beyond max positive int
-020000000001, // float value, beyond max negative int
0.0,
-0.1,
10.0000000000000000005,
10.5e+5,
1e5,
-1e5,
1e-5,
-1e-5,
1e+5,
-1e+5,
1E5,
-1E5,
1E+5,
-1E+5,
1E-5,
-1E-5,
.5e+7,
-.5e+7,
.6e-19,
-.6e-19,
.05E+44,
-.05E+44,
.0034E-30,
-.0034E-30
);
/* loop to check that is_float(), is_double() & is_real() recognizes
different float values, expected: bool(true) */
$loop_counter = 1;
foreach ($floats as $float ) {
echo "-- Iteration $loop_counter --\n"; $loop_counter++;
var_dump( is_float($float) );
var_dump( is_double($float) );
var_dump( is_real($float) );
}
echo "\n*** Testing is_float(), is_double() & is_real() with non float values ***\n";
// get a resource type variable
$fp = fopen (__FILE__, "r");
$dfp = opendir ( dirname(__FILE__) );
// unset variable
$unset_var = 10;
unset ($unset_var);
// non_scalar values, objects, arrays, resources and boolean
class foo
{
var $array = array(10.5);
};
$object = new foo();
$not_floats = array (
new foo, //object
$object,
$fp, // resource
$dfp,
array(), // arrays
array(NULL),
array(0.5e10),
array(1,2,3,4),
array("string"),
NULL, // nulls
null,
true, // boolean
TRUE,
false,
FALSE,
"", // strings
'',
"0",
'0',
"0.0",
'0.0',
'0.5',
"-0.5",
"1e5",
'1e5',
'1.5e6_string',
"1.5e6_string",
1, // integers, hex and octal
-1,
0,
12345,
0xFF55,
-0x673,
0123,
-0123,
@$unset_var, // unset variable
@$undefined_var
);
/* loop through the $not_floats to see working of
is_float(), is_double() & is_real() on objects,
arrays, boolean and others */
$loop_counter = 1;
foreach ($not_floats as $value ) {
echo "--Iteration $loop_counter--\n"; $loop_counter++;
var_dump( is_float($value) );
var_dump( is_double($value) );
var_dump( is_real($value) );
}
echo "\n*** Testing error conditions ***\n";
//Zero argument
var_dump( is_float() );
var_dump( is_double() );
var_dump( is_real() );
//arguments more than expected
var_dump( is_float( $floats[0], $floats[1]) );
var_dump( is_double( $floats[0], $floats[1]) );
var_dump( is_real( $floats[0], $floats[1]) );
echo "Done\n";
?>
--CLEAN--
// close the resources used
fclose($fp);
closedir($dfp);
--EXPECTF--
*** Testing is_float(), is_double() and is_real() with float values***
-- Iteration 1 --
bool(false)
bool(false)
bool(false)
-- Iteration 2 --
bool(false)
bool(false)
bool(false)
-- Iteration 3 --
bool(false)
bool(false)
bool(false)
-- Iteration 4 --
bool(false)
bool(false)
bool(false)
-- Iteration 5 --
bool(false)
bool(false)
bool(false)
-- Iteration 6 --
bool(false)
bool(false)
bool(false)
-- Iteration 7 --
bool(true)
bool(true)
bool(true)
-- Iteration 8 --
bool(true)
bool(true)
bool(true)
-- Iteration 9 --
bool(true)
bool(true)
bool(true)
-- Iteration 10 --
bool(true)
bool(true)
bool(true)
-- Iteration 11 --
bool(true)
bool(true)
bool(true)
-- Iteration 12 --
bool(true)
bool(true)
bool(true)
-- Iteration 13 --
bool(true)
bool(true)
bool(true)
-- Iteration 14 --
bool(true)
bool(true)
bool(true)
-- Iteration 15 --
bool(true)
bool(true)
bool(true)
-- Iteration 16 --
bool(true)
bool(true)
bool(true)
-- Iteration 17 --
bool(true)
bool(true)
bool(true)
-- Iteration 18 --
bool(true)
bool(true)
bool(true)
-- Iteration 19 --
bool(true)
bool(true)
bool(true)
-- Iteration 20 --
bool(true)
bool(true)
bool(true)
-- Iteration 21 --
bool(true)
bool(true)
bool(true)
-- Iteration 22 --
bool(true)
bool(true)
bool(true)
-- Iteration 23 --
bool(true)
bool(true)
bool(true)
-- Iteration 24 --
bool(true)
bool(true)
bool(true)
-- Iteration 25 --
bool(true)
bool(true)
bool(true)
-- Iteration 26 --
bool(true)
bool(true)
bool(true)
-- Iteration 27 --
bool(true)
bool(true)
bool(true)
-- Iteration 28 --
bool(true)
bool(true)
bool(true)
-- Iteration 29 --
bool(true)
bool(true)
bool(true)
-- Iteration 30 --
bool(true)
bool(true)
bool(true)
*** Testing is_float(), is_double() & is_real() with non float values ***
--Iteration 1--
bool(false)
bool(false)
bool(false)
--Iteration 2--
bool(false)
bool(false)
bool(false)
--Iteration 3--
bool(false)
bool(false)
bool(false)
--Iteration 4--
bool(false)
bool(false)
bool(false)
--Iteration 5--
bool(false)
bool(false)
bool(false)
--Iteration 6--
bool(false)
bool(false)
bool(false)
--Iteration 7--
bool(false)
bool(false)
bool(false)
--Iteration 8--
bool(false)
bool(false)
bool(false)
--Iteration 9--
bool(false)
bool(false)
bool(false)
--Iteration 10--
bool(false)
bool(false)
bool(false)
--Iteration 11--
bool(false)
bool(false)
bool(false)
--Iteration 12--
bool(false)
bool(false)
bool(false)
--Iteration 13--
bool(false)
bool(false)
bool(false)
--Iteration 14--
bool(false)
bool(false)
bool(false)
--Iteration 15--
bool(false)
bool(false)
bool(false)
--Iteration 16--
bool(false)
bool(false)
bool(false)
--Iteration 17--
bool(false)
bool(false)
bool(false)
--Iteration 18--
bool(false)
bool(false)
bool(false)
--Iteration 19--
bool(false)
bool(false)
bool(false)
--Iteration 20--
bool(false)
bool(false)
bool(false)
--Iteration 21--
bool(false)
bool(false)
bool(false)
--Iteration 22--
bool(false)
bool(false)
bool(false)
--Iteration 23--
bool(false)
bool(false)
bool(false)
--Iteration 24--
bool(false)
bool(false)
bool(false)
--Iteration 25--
bool(false)
bool(false)
bool(false)
--Iteration 26--
bool(false)
bool(false)
bool(false)
--Iteration 27--
bool(false)
bool(false)
bool(false)
--Iteration 28--
bool(false)
bool(false)
bool(false)
--Iteration 29--
bool(false)
bool(false)
bool(false)
--Iteration 30--
bool(false)
bool(false)
bool(false)
--Iteration 31--
bool(false)
bool(false)
bool(false)
--Iteration 32--
bool(false)
bool(false)
bool(false)
--Iteration 33--
bool(false)
bool(false)
bool(false)
--Iteration 34--
bool(false)
bool(false)
bool(false)
--Iteration 35--
bool(false)
bool(false)
bool(false)
--Iteration 36--
bool(false)
bool(false)
bool(false)
--Iteration 37--
bool(false)
bool(false)
bool(false)
*** Testing error conditions ***
Warning: is_float(): Only one argument expected in %s on line %d
bool(false)
Warning: is_double(): Only one argument expected in %s on line %d
bool(false)
Warning: is_real(): Only one argument expected in %s on line %d
bool(false)
Warning: is_float(): Only one argument expected in %s on line %d
bool(false)
Warning: is_double(): Only one argument expected in %s on line %d
bool(false)
Warning: is_real(): Only one argument expected in %s on line %d
bool(false)
Done

468
ext/standard/tests/general_functions/is_int_64bit.phpt

@ -0,0 +1,468 @@
--TEST--
Test is_int() & it's FALIASes: is_long() & is_integer() functions
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--INI--
precision=14
--FILE--
<?php
/* Prototype: bool is_int ( mixed $var );
* Description: Finds whether the given variable is an integer
*/
echo "*** Testing is_int(), is_integer() & is_long() with valid integer values ***\n";
// different valid integer vlaues
$valid_ints = array(
0,
1,
-1,
-2147483648, // max negative integer value
-2147483647,
2147483647, // max positive integer value
2147483640,
0x123B, // integer as hexadecimal
0x12ab,
0Xfff,
0XFA,
-0x80000000, // max negative integer as hexadecimal
0x7fffffff, // max postive integer as hexadecimal
0x7FFFFFFF, // max postive integer as hexadecimal
0123, // integer as octal
01912, // should be quivalent to octal 1
-020000000000, // max negative integer as octal
017777777777, // max positive integer as octal
);
/* loop to check that is_int() recognizes different
integer values, expected output: bool(true) */
$loop_counter = 1;
foreach ($valid_ints as $int_val ) {
echo "--Iteration $loop_counter--\n"; $loop_counter++;
var_dump( is_int($int_val) );
var_dump( is_integer($int_val) );
var_dump( is_long($int_val) );
}
echo "\n*** Testing is_int(), is_integer() & is_long() with non integer values ***\n";
// resource type variable
$fp = fopen (__FILE__, "r");
$dfp = opendir ( dirname(__FILE__) );
// unset variable
$unset_var = 10;
unset ($unset_var);
// other types in a array
$not_int_types = array (
/* float values */
-2147483649, // float value
2147483648, // float value
-0x80000001, // float value, beyond max negative int
0x800000001, // float value, beyond max positive int
020000000001, // float value, beyond max positive int
-020000000001, // float value, beyond max negative int
0.0,
-0.1,
1.0,
1e5,
-1e6,
1E8,
-1E9,
10.0000000000000000005,
10.5e+5,
/* objects */
new stdclass,
/* resources */
$fp,
$dfp,
/* arrays */
array(),
array(0),
array(1),
array(NULL),
array(null),
array("string"),
array(true),
array(TRUE),
array(false),
array(FALSE),
array(1,2,3,4),
array(1 => "One", "two" => 2),
/* strings */
"",
'',
"0",
'0',
"1",
'1',
"\x01",
'\x01',
"\01",
'\01',
'string',
"string",
"true",
"FALSE",
'false',
'TRUE',
"NULL",
'null',
/* booleans */
true,
false,
TRUE,
FALSE,
/* undefined and unset vars */
@$unset_var,
@$undefined_var
);
/* loop through the $not_int_types to see working of
is_int() on non integer types, expected output: bool(false) */
$loop_counter = 1;
foreach ($not_int_types as $type ) {
echo "--Iteration $loop_counter--\n"; $loop_counter++;
var_dump( is_int($type) );
var_dump( is_integer($type) );
var_dump( is_long($type) );
}
echo "\n*** Testing error conditions ***\n";
//Zero argument
var_dump( is_int() );
var_dump( is_integer() );
var_dump( is_long() );
//arguments more than expected
var_dump( is_int(TRUE, FALSE) );
var_dump( is_integer(TRUE, FALSE) );
var_dump( is_long(TRUE, FALSE) );
echo "Done\n";
?>
--CLEAN--
// close the resources
fclose($fp);
closedir($dfp);
--EXPECTF--
*** Testing is_int(), is_integer() & is_long() with valid integer values ***
--Iteration 1--
bool(true)
bool(true)
bool(true)
--Iteration 2--
bool(true)
bool(true)
bool(true)
--Iteration 3--
bool(true)
bool(true)
bool(true)
--Iteration 4--
bool(true)
bool(true)
bool(true)
--Iteration 5--
bool(true)
bool(true)
bool(true)
--Iteration 6--
bool(true)
bool(true)
bool(true)
--Iteration 7--
bool(true)
bool(true)
bool(true)
--Iteration 8--
bool(true)
bool(true)
bool(true)
--Iteration 9--
bool(true)
bool(true)
bool(true)
--Iteration 10--
bool(true)
bool(true)
bool(true)
--Iteration 11--
bool(true)
bool(true)
bool(true)
--Iteration 12--
bool(true)
bool(true)
bool(true)
--Iteration 13--
bool(true)
bool(true)
bool(true)
--Iteration 14--
bool(true)
bool(true)
bool(true)
--Iteration 15--
bool(true)
bool(true)
bool(true)
--Iteration 16--
bool(true)
bool(true)
bool(true)
--Iteration 17--
bool(true)
bool(true)
bool(true)
--Iteration 18--
bool(true)
bool(true)
bool(true)
*** Testing is_int(), is_integer() & is_long() with non integer values ***
--Iteration 1--
bool(true)
bool(true)
bool(true)
--Iteration 2--
bool(true)
bool(true)
bool(true)
--Iteration 3--
bool(true)
bool(true)
bool(true)
--Iteration 4--
bool(true)
bool(true)
bool(true)
--Iteration 5--
bool(true)
bool(true)
bool(true)
--Iteration 6--
bool(true)
bool(true)
bool(true)
--Iteration 7--
bool(false)
bool(false)
bool(false)
--Iteration 8--
bool(false)
bool(false)
bool(false)
--Iteration 9--
bool(false)
bool(false)
bool(false)
--Iteration 10--
bool(false)
bool(false)
bool(false)
--Iteration 11--
bool(false)
bool(false)
bool(false)
--Iteration 12--
bool(false)
bool(false)
bool(false)
--Iteration 13--
bool(false)
bool(false)
bool(false)
--Iteration 14--
bool(false)
bool(false)
bool(false)
--Iteration 15--
bool(false)
bool(false)
bool(false)
--Iteration 16--
bool(false)
bool(false)
bool(false)
--Iteration 17--
bool(false)
bool(false)
bool(false)
--Iteration 18--
bool(false)
bool(false)
bool(false)
--Iteration 19--
bool(false)
bool(false)
bool(false)
--Iteration 20--
bool(false)
bool(false)
bool(false)
--Iteration 21--
bool(false)
bool(false)
bool(false)
--Iteration 22--
bool(false)
bool(false)
bool(false)
--Iteration 23--
bool(false)
bool(false)
bool(false)
--Iteration 24--
bool(false)
bool(false)
bool(false)
--Iteration 25--
bool(false)
bool(false)
bool(false)
--Iteration 26--
bool(false)
bool(false)
bool(false)
--Iteration 27--
bool(false)
bool(false)
bool(false)
--Iteration 28--
bool(false)
bool(false)
bool(false)
--Iteration 29--
bool(false)
bool(false)
bool(false)
--Iteration 30--
bool(false)
bool(false)
bool(false)
--Iteration 31--
bool(false)
bool(false)
bool(false)
--Iteration 32--
bool(false)
bool(false)
bool(false)
--Iteration 33--
bool(false)
bool(false)
bool(false)
--Iteration 34--
bool(false)
bool(false)
bool(false)
--Iteration 35--
bool(false)
bool(false)
bool(false)
--Iteration 36--
bool(false)
bool(false)
bool(false)
--Iteration 37--
bool(false)
bool(false)
bool(false)
--Iteration 38--
bool(false)
bool(false)
bool(false)
--Iteration 39--
bool(false)
bool(false)
bool(false)
--Iteration 40--
bool(false)
bool(false)
bool(false)
--Iteration 41--
bool(false)
bool(false)
bool(false)
--Iteration 42--
bool(false)
bool(false)
bool(false)
--Iteration 43--
bool(false)
bool(false)
bool(false)
--Iteration 44--
bool(false)
bool(false)
bool(false)
--Iteration 45--
bool(false)
bool(false)
bool(false)
--Iteration 46--
bool(false)
bool(false)
bool(false)
--Iteration 47--
bool(false)
bool(false)
bool(false)
--Iteration 48--
bool(false)
bool(false)
bool(false)
--Iteration 49--
bool(false)
bool(false)
bool(false)
--Iteration 50--
bool(false)
bool(false)
bool(false)
--Iteration 51--
bool(false)
bool(false)
bool(false)
--Iteration 52--
bool(false)
bool(false)
bool(false)
--Iteration 53--
bool(false)
bool(false)
bool(false)
--Iteration 54--
bool(false)
bool(false)
bool(false)
*** Testing error conditions ***
Warning: is_int(): Only one argument expected in %s on line %d
bool(false)
Warning: is_integer(): Only one argument expected in %s on line %d
bool(false)
Warning: is_long(): Only one argument expected in %s on line %d
bool(false)
Warning: is_int(): Only one argument expected in %s on line %d
bool(false)
Warning: is_integer(): Only one argument expected in %s on line %d
bool(false)
Warning: is_long(): Only one argument expected in %s on line %d
bool(false)
Done

1740
ext/standard/tests/general_functions/print_r_64bit.phpt
File diff suppressed because it is too large
View File

1913
ext/standard/tests/general_functions/var_dump_64bit.phpt
File diff suppressed because it is too large
View File

Loading…
Cancel
Save