Annotation of embedaddon/php/ext/mbstring/tests/mb_regex_encoding_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_regex_encoding() function : usage variations - Pass different data types as $encoding arg
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_regex_encoding') or die("skip mb_regex_encoding() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : string mb_regex_encoding([string $encoding])
11: * Description: Returns the current encoding for regex as a string.
12: * Source code: ext/mbstring/php_mbregex.c
13: */
14:
15: /*
16: * Pass different data types as $encoding argument to mb_regex_encoding() to test behaviour
17: * Where possible, 'UTF-8' has been entered as a string value
18: */
19:
20: echo "*** Testing mb_regex_encoding() : usage variations ***\n";
21: //get an unset variable
22: $unset_var = 10;
23: unset ($unset_var);
24:
25: // get a class
26: class classA
27: {
28: public function __toString() {
29: return "UTF-8";
30: }
31: }
32:
33: // heredoc string
34: $heredoc = <<<EOT
35: UTF-8
36: EOT;
37:
38: // get a resource variable
39: $fp = fopen(__FILE__, "r");
40:
41: // unexpected values to be passed to $encoding argument
42: $inputs = array(
43:
44: // int data
45: /*1*/ 0,
46: 1,
47: 12345,
48: -2345,
49:
50: // float data
51: /*5*/ 10.5,
52: -10.5,
53: 12.3456789000e10,
54: 12.3456789000E-10,
55: .5,
56:
57: // null data
58: /*10*/ NULL,
59: null,
60:
61: // boolean data
62: /*12*/ true,
63: false,
64: TRUE,
65: FALSE,
66:
67: // empty data
68: /*16*/ "",
69: '',
70:
71: // string data
72: /*18*/ "UTF-8",
73: 'UTF-8',
74: $heredoc,
75:
76: // object data
77: /*21*/ new classA(),
78:
79: // undefined data
80: /*22*/ @$undefined_var,
81:
82: // unset data
83: /*23*/ @$unset_var,
84:
85: // resource variable
86: /*24*/ $fp
87: );
88:
89: // loop through each element of $inputs to check the behavior of mb_regex_encoding()
90: $iterator = 1;
91: foreach($inputs as $input) {
92: echo "\n-- Iteration $iterator --\n";
93: var_dump( mb_regex_encoding($input) );
94: $iterator++;
95: };
96:
97: fclose($fp);
98:
99: echo "Done";
100: ?>
101: --EXPECTF--
102: *** Testing mb_regex_encoding() : usage variations ***
103:
104: -- Iteration 1 --
105:
106: Warning: mb_regex_encoding(): Unknown encoding "0" in %s on line %d
107: bool(false)
108:
109: -- Iteration 2 --
110:
111: Warning: mb_regex_encoding(): Unknown encoding "1" in %s on line %d
112: bool(false)
113:
114: -- Iteration 3 --
115:
116: Warning: mb_regex_encoding(): Unknown encoding "12345" in %s on line %d
117: bool(false)
118:
119: -- Iteration 4 --
120:
121: Warning: mb_regex_encoding(): Unknown encoding "-2345" in %s on line %d
122: bool(false)
123:
124: -- Iteration 5 --
125:
126: Warning: mb_regex_encoding(): Unknown encoding "10.5" in %s on line %d
127: bool(false)
128:
129: -- Iteration 6 --
130:
131: Warning: mb_regex_encoding(): Unknown encoding "-10.5" in %s on line %d
132: bool(false)
133:
134: -- Iteration 7 --
135:
136: Warning: mb_regex_encoding(): Unknown encoding "123456789000" in %s on line %d
137: bool(false)
138:
139: -- Iteration 8 --
140:
141: Warning: mb_regex_encoding(): Unknown encoding "1.23456789E-9" in %s on line %d
142: bool(false)
143:
144: -- Iteration 9 --
145:
146: Warning: mb_regex_encoding(): Unknown encoding "0.5" in %s on line %d
147: bool(false)
148:
149: -- Iteration 10 --
150:
151: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
152: bool(false)
153:
154: -- Iteration 11 --
155:
156: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
157: bool(false)
158:
159: -- Iteration 12 --
160:
161: Warning: mb_regex_encoding(): Unknown encoding "1" in %s on line %d
162: bool(false)
163:
164: -- Iteration 13 --
165:
166: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
167: bool(false)
168:
169: -- Iteration 14 --
170:
171: Warning: mb_regex_encoding(): Unknown encoding "1" in %s on line %d
172: bool(false)
173:
174: -- Iteration 15 --
175:
176: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
177: bool(false)
178:
179: -- Iteration 16 --
180:
181: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
182: bool(false)
183:
184: -- Iteration 17 --
185:
186: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
187: bool(false)
188:
189: -- Iteration 18 --
190: bool(true)
191:
192: -- Iteration 19 --
193: bool(true)
194:
195: -- Iteration 20 --
196: bool(true)
197:
198: -- Iteration 21 --
199: bool(true)
200:
201: -- Iteration 22 --
202:
203: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
204: bool(false)
205:
206: -- Iteration 23 --
207:
208: Warning: mb_regex_encoding(): Unknown encoding "" in %s on line %d
209: bool(false)
210:
211: -- Iteration 24 --
212:
213: Warning: mb_regex_encoding() expects parameter 1 to be string, resource given in %s on line %d
214: NULL
215: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>