1--TEST--
2Test token_get_all() function : usage variations - with different arithmetic operators
3--SKIPIF--
4<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
5--FILE--
6<?php
7/* Prototype  : array token_get_all(string $source)
8 * Description: splits the given source into an array of PHP languange tokens
9 * Source code: ext/tokenizer/tokenizer.c
10*/
11
12/*
13 * Passing 'source' argument with different arithmetic operators to test them for token
14 * Arithmetic operators: +, -, *, /, % are not listed as specific operator tokens,
15 *    so they are expected to return string - T_STRING
16*/
17
18echo "*** Testing token_get_all() : 'source' string with different arithmetic operators ***\n";
19
20// arithmetic operators - '+', '-', '*', '/', '%'
21$source = array (
22  '<?php $a = 1 + 2; ?>',
23  '<?php $b = $b - 2; ?>',
24  '<?php $c = $a * $b; ?>',
25  '<?php $a = $b % 2; ?>'
26);
27for($count = 0; $count < count($source); $count++) {
28  echo "-- Iteration ".($count + 1)." --\n";
29  var_dump( token_get_all($source[$count]));
30}
31echo "Done"
32?>
33--EXPECTF--
34*** Testing token_get_all() : 'source' string with different arithmetic operators ***
35-- Iteration 1 --
36array(13) {
37  [0]=>
38  array(3) {
39    [0]=>
40    int(%d)
41    [1]=>
42    string(6) "<?php "
43    [2]=>
44    int(1)
45  }
46  [1]=>
47  array(3) {
48    [0]=>
49    int(%d)
50    [1]=>
51    string(2) "$a"
52    [2]=>
53    int(1)
54  }
55  [2]=>
56  array(3) {
57    [0]=>
58    int(%d)
59    [1]=>
60    string(1) " "
61    [2]=>
62    int(1)
63  }
64  [3]=>
65  string(1) "="
66  [4]=>
67  array(3) {
68    [0]=>
69    int(%d)
70    [1]=>
71    string(1) " "
72    [2]=>
73    int(1)
74  }
75  [5]=>
76  array(3) {
77    [0]=>
78    int(%d)
79    [1]=>
80    string(1) "1"
81    [2]=>
82    int(1)
83  }
84  [6]=>
85  array(3) {
86    [0]=>
87    int(%d)
88    [1]=>
89    string(1) " "
90    [2]=>
91    int(1)
92  }
93  [7]=>
94  string(1) "+"
95  [8]=>
96  array(3) {
97    [0]=>
98    int(%d)
99    [1]=>
100    string(1) " "
101    [2]=>
102    int(1)
103  }
104  [9]=>
105  array(3) {
106    [0]=>
107    int(%d)
108    [1]=>
109    string(1) "2"
110    [2]=>
111    int(1)
112  }
113  [10]=>
114  string(1) ";"
115  [11]=>
116  array(3) {
117    [0]=>
118    int(%d)
119    [1]=>
120    string(1) " "
121    [2]=>
122    int(1)
123  }
124  [12]=>
125  array(3) {
126    [0]=>
127    int(%d)
128    [1]=>
129    string(2) "?>"
130    [2]=>
131    int(1)
132  }
133}
134-- Iteration 2 --
135array(13) {
136  [0]=>
137  array(3) {
138    [0]=>
139    int(%d)
140    [1]=>
141    string(6) "<?php "
142    [2]=>
143    int(1)
144  }
145  [1]=>
146  array(3) {
147    [0]=>
148    int(%d)
149    [1]=>
150    string(2) "$b"
151    [2]=>
152    int(1)
153  }
154  [2]=>
155  array(3) {
156    [0]=>
157    int(%d)
158    [1]=>
159    string(1) " "
160    [2]=>
161    int(1)
162  }
163  [3]=>
164  string(1) "="
165  [4]=>
166  array(3) {
167    [0]=>
168    int(%d)
169    [1]=>
170    string(1) " "
171    [2]=>
172    int(1)
173  }
174  [5]=>
175  array(3) {
176    [0]=>
177    int(%d)
178    [1]=>
179    string(2) "$b"
180    [2]=>
181    int(1)
182  }
183  [6]=>
184  array(3) {
185    [0]=>
186    int(%d)
187    [1]=>
188    string(1) " "
189    [2]=>
190    int(1)
191  }
192  [7]=>
193  string(1) "-"
194  [8]=>
195  array(3) {
196    [0]=>
197    int(%d)
198    [1]=>
199    string(1) " "
200    [2]=>
201    int(1)
202  }
203  [9]=>
204  array(3) {
205    [0]=>
206    int(%d)
207    [1]=>
208    string(1) "2"
209    [2]=>
210    int(1)
211  }
212  [10]=>
213  string(1) ";"
214  [11]=>
215  array(3) {
216    [0]=>
217    int(%d)
218    [1]=>
219    string(1) " "
220    [2]=>
221    int(1)
222  }
223  [12]=>
224  array(3) {
225    [0]=>
226    int(%d)
227    [1]=>
228    string(2) "?>"
229    [2]=>
230    int(1)
231  }
232}
233-- Iteration 3 --
234array(13) {
235  [0]=>
236  array(3) {
237    [0]=>
238    int(%d)
239    [1]=>
240    string(6) "<?php "
241    [2]=>
242    int(1)
243  }
244  [1]=>
245  array(3) {
246    [0]=>
247    int(%d)
248    [1]=>
249    string(2) "$c"
250    [2]=>
251    int(1)
252  }
253  [2]=>
254  array(3) {
255    [0]=>
256    int(%d)
257    [1]=>
258    string(1) " "
259    [2]=>
260    int(1)
261  }
262  [3]=>
263  string(1) "="
264  [4]=>
265  array(3) {
266    [0]=>
267    int(%d)
268    [1]=>
269    string(1) " "
270    [2]=>
271    int(1)
272  }
273  [5]=>
274  array(3) {
275    [0]=>
276    int(%d)
277    [1]=>
278    string(2) "$a"
279    [2]=>
280    int(1)
281  }
282  [6]=>
283  array(3) {
284    [0]=>
285    int(%d)
286    [1]=>
287    string(1) " "
288    [2]=>
289    int(1)
290  }
291  [7]=>
292  string(1) "*"
293  [8]=>
294  array(3) {
295    [0]=>
296    int(%d)
297    [1]=>
298    string(1) " "
299    [2]=>
300    int(1)
301  }
302  [9]=>
303  array(3) {
304    [0]=>
305    int(%d)
306    [1]=>
307    string(2) "$b"
308    [2]=>
309    int(1)
310  }
311  [10]=>
312  string(1) ";"
313  [11]=>
314  array(3) {
315    [0]=>
316    int(%d)
317    [1]=>
318    string(1) " "
319    [2]=>
320    int(1)
321  }
322  [12]=>
323  array(3) {
324    [0]=>
325    int(%d)
326    [1]=>
327    string(2) "?>"
328    [2]=>
329    int(1)
330  }
331}
332-- Iteration 4 --
333array(13) {
334  [0]=>
335  array(3) {
336    [0]=>
337    int(%d)
338    [1]=>
339    string(6) "<?php "
340    [2]=>
341    int(1)
342  }
343  [1]=>
344  array(3) {
345    [0]=>
346    int(%d)
347    [1]=>
348    string(2) "$a"
349    [2]=>
350    int(1)
351  }
352  [2]=>
353  array(3) {
354    [0]=>
355    int(%d)
356    [1]=>
357    string(1) " "
358    [2]=>
359    int(1)
360  }
361  [3]=>
362  string(1) "="
363  [4]=>
364  array(3) {
365    [0]=>
366    int(%d)
367    [1]=>
368    string(1) " "
369    [2]=>
370    int(1)
371  }
372  [5]=>
373  array(3) {
374    [0]=>
375    int(%d)
376    [1]=>
377    string(2) "$b"
378    [2]=>
379    int(1)
380  }
381  [6]=>
382  array(3) {
383    [0]=>
384    int(%d)
385    [1]=>
386    string(1) " "
387    [2]=>
388    int(1)
389  }
390  [7]=>
391  string(1) "%"
392  [8]=>
393  array(3) {
394    [0]=>
395    int(%d)
396    [1]=>
397    string(1) " "
398    [2]=>
399    int(1)
400  }
401  [9]=>
402  array(3) {
403    [0]=>
404    int(%d)
405    [1]=>
406    string(1) "2"
407    [2]=>
408    int(1)
409  }
410  [10]=>
411  string(1) ";"
412  [11]=>
413  array(3) {
414    [0]=>
415    int(%d)
416    [1]=>
417    string(1) " "
418    [2]=>
419    int(1)
420  }
421  [12]=>
422  array(3) {
423    [0]=>
424    int(%d)
425    [1]=>
426    string(2) "?>"
427    [2]=>
428    int(1)
429  }
430}
431Done
432