import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-general_functions / is_int.php
blob53209c8905e4b850820452f5d3e5c06544b9b9c7
1 <?php
2 /* Prototype: bool is_int ( mixed $var );
3 * Description: Finds whether the given variable is an integer
4 */
6 echo "*** Testing is_int(), is_integer() & is_long() with valid integer values ***\n";
7 // different valid integer vlaues
8 $valid_ints = array(
9 0,
11 -1,
12 -2147483648, // max negative integer value
13 -2147483647,
14 2147483647, // max positive integer value
15 2147483640,
16 0x123B, // integer as hexadecimal
17 0x12ab,
18 0Xfff,
19 0XFA,
20 -0x80000000, // max negative integer as hexadecimal
21 0x7fffffff, // max postive integer as hexadecimal
22 0x7FFFFFFF, // max postive integer as hexadecimal
23 0123, // integer as octal
24 01912, // should be quivalent to octal 1
25 -020000000000, // max negative integer as octal
26 017777777777, // max positive integer as octal
28 /* loop to check that is_int() recognizes different
29 integer values, expected output: bool(true) */
30 $loop_counter = 1;
31 foreach ($valid_ints as $int_val ) {
32 echo "--Iteration $loop_counter--\n"; $loop_counter++;
33 var_dump( is_int($int_val) );
34 var_dump( is_integer($int_val) );
35 var_dump( is_long($int_val) );
38 echo "\n*** Testing is_int(), is_integer() & is_long() with non integer values ***\n";
40 // resource type variable
41 $fp = fopen (__FILE__, "r");
42 $dfp = opendir ( dirname(__FILE__) );
43 // unset variable
45 $unset_var = 10;
46 unset ($unset_var);
48 // other types in a array
49 $not_int_types = array (
50 /* float values */
51 -2147483649, // float value
52 2147483648, // float value
53 -0x80000001, // float value, beyond max negative int
54 0x800000001, // float value, beyond max positive int
55 020000000001, // float value, beyond max positive int
56 -020000000001, // float value, beyond max negative int
57 0.0,
58 -0.1,
59 1.0,
60 1e5,
61 -1e6,
62 1E8,
63 -1E9,
64 10.0000000000000000005,
65 10.5e+5,
67 /* objects */
68 new stdclass,
70 /* resources */
71 $fp,
72 $dfp,
74 /* arrays */
75 array(),
76 array(0),
77 array(1),
78 array(NULL),
79 array(null),
80 array("string"),
81 array(true),
82 array(TRUE),
83 array(false),
84 array(FALSE),
85 array(1,2,3,4),
86 array(1 => "One", "two" => 2),
88 /* strings */
89 "",
90 '',
91 "0",
92 '0',
93 "1",
94 '1',
95 "\x01",
96 '\x01',
97 "\01",
98 '\01',
99 'string',
100 "string",
101 "true",
102 "FALSE",
103 'false',
104 'TRUE',
105 "NULL",
106 'null',
108 /* booleans */
109 true,
110 false,
111 TRUE,
112 FALSE,
114 /* undefined and unset vars */
115 @$unset_var,
116 @$undefined_var
118 /* loop through the $not_int_types to see working of
119 is_int() on non integer types, expected output: bool(false) */
120 $loop_counter = 1;
121 foreach ($not_int_types as $type ) {
122 echo "--Iteration $loop_counter--\n"; $loop_counter++;
123 var_dump( is_int($type) );
124 var_dump( is_integer($type) );
125 var_dump( is_long($type) );
128 echo "\n*** Testing error conditions ***\n";
129 //Zero argument
130 var_dump( is_int() );
131 var_dump( is_integer() );
132 var_dump( is_long() );
134 //arguments more than expected
135 var_dump( is_int(TRUE, FALSE) );
136 var_dump( is_integer(TRUE, FALSE) );
137 var_dump( is_long(TRUE, FALSE) );
139 echo "Done\n";
141 // close the resources
142 fclose($fp);
143 closedir($dfp);