import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-general_functions / is_bool.php
blobbad0702e0c79defbd8bd2e262aa0697ef6d26c95
1 <?php
2 /* Prototype: bool is_bool ( mixed $var );
3 * Description: Finds whether the given variable is a boolean
4 */
6 echo "*** Testing is_bool() with valid boolean values ***\n";
7 // different valid boolean vlaues
8 $valid_bools = array(
9 TRUE,
10 FALSE,
11 true,
12 false,
14 /* loop to check that is_bool() recognizes different
15 bool values, expected output: bool(true) */
16 $loop_counter = 1;
17 foreach ($valid_bools as $bool_val ) {
18 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
19 var_dump( is_bool($bool_val) );
22 echo "\n*** Testing is_bool() on non boolean values ***\n";
24 // get a resource type variable
25 $fp = fopen (__FILE__, "r");
26 $dfp = opendir ( dirname(__FILE__) );
28 // unset variable
29 $unset_bool1 = true;
30 $unset_bool2 = false;
31 $unset_var = 0;
32 unset ($unset_bool1);
33 unset ($unset_bool2);
34 unset ($unset_var);
36 // other types in a array
37 $not_bool_types = array (
38 /* integers */
41 -1,
42 -0,
43 543915,
44 -5322,
45 0x0,
46 0x1,
47 0x55F,
48 -0xCCF,
49 0123,
50 -0654,
51 00,
52 01,
54 /* strings */
55 "",
56 '',
57 "0",
58 '0',
59 "1",
60 '1',
61 'string',
62 "string",
63 "true",
64 "false",
65 "FALSE",
66 "TRUE",
67 'true',
68 'false',
69 'FALSE',
70 'TRUE',
71 "NULL",
72 "null",
74 /* floats */
75 0.0,
76 1.0,
77 -1.0,
78 10.0000000000000000005,
79 .5e6,
80 -.5E7,
81 .5E+8,
82 -.5e+90,
83 1e5,
84 -1e5,
85 1E5,
86 -1E7,
88 /* objects */
89 new stdclass,
91 /* resources */
92 $fp,
93 $dfp,
95 /* nulls */
96 null,
97 NULL,
99 /* arrays */
100 array(),
101 array(0),
102 array(1),
103 array(NULL),
104 array(null),
105 array("string"),
106 array(true),
107 array(TRUE),
108 array(false),
109 array(FALSE),
110 array(1,2,3,4),
111 array(1 => "One", "two" => 2),
113 /* unset bool vars and undefined var */
114 @$unset_bool1,
115 @$unset_bool2,
116 @$unset_var,
117 @$undefined_var
119 /* loop through the $not_bool_types to see working of
120 is_bool() on non bull types, expected output: bool(false) */
121 $loop_counter = 1;
122 foreach ($not_bool_types as $type ) {
123 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
124 var_dump( is_bool($type) );
127 echo "\n*** Testing error conditions ***\n";
128 //Zero argument
129 var_dump( is_bool() );
131 //arguments more than expected
132 var_dump( is_bool(TRUE, FALSE) );
134 echo "Done\n";
136 // close resources
137 fclose($fp);
138 closedir($dfp);