Annotation of embedaddon/php/ext/ctype/tests/ctype_cntrl_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test ctype_cntrl() function : usage variations - Different data types as $c arg
3: --SKIPIF--
4: <?php require_once('skipif.inc'); ?>
5: --FILE--
6: <?php
7: /* Prototype : bool ctype_cntrl(mixed $c)
8: * Description: Checks for control character(s)
9: * Source code: ext/ctype/ctype.c
10: */
11:
12: /*
13: * Pass different data types as $c argument to ctype_cntrl() to test behaviour
14: */
15:
16: echo "*** Testing ctype_cntrl() : usage variations ***\n";
17:
18: $orig = setlocale(LC_CTYPE, "C");
19:
20: //get an unset variable
21: $unset_var = 10;
22: unset ($unset_var);
23:
24: // get a class
25: class classA
26: {
27: public function __toString() {
28: return "\n\r\t";
29: }
30: }
31:
32: // heredoc string
33: $heredoc = <<<EOT
34: \t\r\n
35: EOT;
36:
37: // get a resource variable
38: $fp = fopen(__FILE__, "r");
39:
40: // unexpected values to be passed to $c argument
41: $inputs = array(
42:
43: // int data
44: /*1*/ 0,
45: 1,
46: 12345,
47: -2345,
48:
49: // float data
50: /*5*/ 10.5,
51: -10.5,
52: 12.3456789000e10,
53: 12.3456789000E-10,
54: .5,
55:
56: // null data
57: /*10*/ NULL,
58: null,
59:
60: // boolean data
61: /*12*/ true,
62: false,
63: TRUE,
64: FALSE,
65:
66: // empty data
67: /*16*/ "",
68: '',
69: array(),
70:
71: // string data
72: /*19*/ "\t\r\n",
73: '
74: ',
75: $heredoc,
76:
77: // object data
78: /*22*/ new classA(),
79:
80: // undefined data
81: /*23*/ @$undefined_var,
82:
83: // unset data
84: /*24*/ @$unset_var,
85:
86: // resource variable
87: /*25*/ $fp
88: );
89:
90: // loop through each element of $inputs to check the behavior of ctype_cntrl()
91: $iterator = 1;
92: foreach($inputs as $input) {
93: echo "\n-- Iteration $iterator --\n";
94: var_dump( ctype_cntrl($input) );
95: $iterator++;
96: };
97:
98: fclose($fp);
99:
100: setlocale(LC_CTYPE, $orig);
101: ?>
102: ===DONE===
103: --EXPECTF--
104: *** Testing ctype_cntrl() : usage variations ***
105:
106: -- Iteration 1 --
107: bool(true)
108:
109: -- Iteration 2 --
110: bool(true)
111:
112: -- Iteration 3 --
113: bool(false)
114:
115: -- Iteration 4 --
116: bool(false)
117:
118: -- Iteration 5 --
119: bool(false)
120:
121: -- Iteration 6 --
122: bool(false)
123:
124: -- Iteration 7 --
125: bool(false)
126:
127: -- Iteration 8 --
128: bool(false)
129:
130: -- Iteration 9 --
131: bool(false)
132:
133: -- Iteration 10 --
134: bool(false)
135:
136: -- Iteration 11 --
137: bool(false)
138:
139: -- Iteration 12 --
140: bool(false)
141:
142: -- Iteration 13 --
143: bool(false)
144:
145: -- Iteration 14 --
146: bool(false)
147:
148: -- Iteration 15 --
149: bool(false)
150:
151: -- Iteration 16 --
152: bool(false)
153:
154: -- Iteration 17 --
155: bool(false)
156:
157: -- Iteration 18 --
158: bool(false)
159:
160: -- Iteration 19 --
161: bool(true)
162:
163: -- Iteration 20 --
164: bool(true)
165:
166: -- Iteration 21 --
167: bool(true)
168:
169: -- Iteration 22 --
170: bool(false)
171:
172: -- Iteration 23 --
173: bool(false)
174:
175: -- Iteration 24 --
176: bool(false)
177:
178: -- Iteration 25 --
179: bool(false)
180: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>