Annotation of embedaddon/php/ext/tokenizer/tests/token_get_all_variation17.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test token_get_all() function : usage variations - with exception keywords
3: --FILE--
4: <?php
5: /* Prototype : array token_get_all(string $source)
6: * Description: splits the given source into an array of PHP languange tokens
7: * Source code: ext/tokenizer/tokenizer.c
8: */
9:
10: /*
11: * Testing token_get_all() with different exception keywords
12: * try - T_TRY(336),
13: * catch - T_CATCH(337),
14: * throw - T_THROW(338)
15: */
16:
17: echo "*** Testing token_get_all() : with exception keywords ***\n";
18:
19: $source = '<?php
20: function inverse($x)
21: {
22: if($x == 0) {
23: throw new Exception("Divison by zero");
24: else
25: return 1/$x;
26: }
27: try {
28: echo inverse(0);
29: echo inverse(5);
30: } catch(Exception $e) {
31: echo "caught exception:";
32: }
33: ?>';
34: $tokens = token_get_all($source);
35: var_dump($tokens);
36:
37: echo "Done"
38: ?>
39: --EXPECTF--
40: *** Testing token_get_all() : with exception keywords ***
41: array(81) {
42: [0]=>
43: array(3) {
44: [0]=>
45: int(368)
46: [1]=>
47: string(6) "<?php
48: "
49: [2]=>
50: int(1)
51: }
52: [1]=>
53: array(3) {
54: [0]=>
55: int(334)
56: [1]=>
57: string(8) "function"
58: [2]=>
59: int(2)
60: }
61: [2]=>
62: array(3) {
63: [0]=>
64: int(371)
65: [1]=>
66: string(1) " "
67: [2]=>
68: int(2)
69: }
70: [3]=>
71: array(3) {
72: [0]=>
73: int(307)
74: [1]=>
75: string(7) "inverse"
76: [2]=>
77: int(2)
78: }
79: [4]=>
80: string(1) "("
81: [5]=>
82: array(3) {
83: [0]=>
84: int(309)
85: [1]=>
86: string(2) "$x"
87: [2]=>
88: int(2)
89: }
90: [6]=>
91: string(1) ")"
92: [7]=>
93: array(3) {
94: [0]=>
95: int(371)
96: [1]=>
97: string(1) "
98: "
99: [2]=>
100: int(2)
101: }
102: [8]=>
103: string(1) "{"
104: [9]=>
105: array(3) {
106: [0]=>
107: int(371)
108: [1]=>
109: string(3) "
110: "
111: [2]=>
112: int(3)
113: }
114: [10]=>
115: array(3) {
116: [0]=>
117: int(301)
118: [1]=>
119: string(2) "if"
120: [2]=>
121: int(4)
122: }
123: [11]=>
124: string(1) "("
125: [12]=>
126: array(3) {
127: [0]=>
128: int(309)
129: [1]=>
130: string(2) "$x"
131: [2]=>
132: int(4)
133: }
134: [13]=>
135: array(3) {
136: [0]=>
137: int(371)
138: [1]=>
139: string(1) " "
140: [2]=>
141: int(4)
142: }
143: [14]=>
144: array(3) {
145: [0]=>
146: int(283)
147: [1]=>
148: string(2) "=="
149: [2]=>
150: int(4)
151: }
152: [15]=>
153: array(3) {
154: [0]=>
155: int(371)
156: [1]=>
157: string(1) " "
158: [2]=>
159: int(4)
160: }
161: [16]=>
162: array(3) {
163: [0]=>
164: int(305)
165: [1]=>
166: string(1) "0"
167: [2]=>
168: int(4)
169: }
170: [17]=>
171: string(1) ")"
172: [18]=>
173: array(3) {
174: [0]=>
175: int(371)
176: [1]=>
177: string(1) " "
178: [2]=>
179: int(4)
180: }
181: [19]=>
182: string(1) "{"
183: [20]=>
184: array(3) {
185: [0]=>
186: int(371)
187: [1]=>
188: string(5) "
189: "
190: [2]=>
191: int(4)
192: }
193: [21]=>
194: array(3) {
195: [0]=>
196: int(339)
197: [1]=>
198: string(5) "throw"
199: [2]=>
200: int(5)
201: }
202: [22]=>
203: array(3) {
204: [0]=>
205: int(371)
206: [1]=>
207: string(1) " "
208: [2]=>
209: int(5)
210: }
211: [23]=>
212: array(3) {
213: [0]=>
214: int(299)
215: [1]=>
216: string(3) "new"
217: [2]=>
218: int(5)
219: }
220: [24]=>
221: array(3) {
222: [0]=>
223: int(371)
224: [1]=>
225: string(1) " "
226: [2]=>
227: int(5)
228: }
229: [25]=>
230: array(3) {
231: [0]=>
232: int(307)
233: [1]=>
234: string(9) "Exception"
235: [2]=>
236: int(5)
237: }
238: [26]=>
239: string(1) "("
240: [27]=>
241: array(3) {
242: [0]=>
243: int(315)
244: [1]=>
245: string(17) ""Divison by zero""
246: [2]=>
247: int(5)
248: }
249: [28]=>
250: string(1) ")"
251: [29]=>
252: string(1) ";"
253: [30]=>
254: array(3) {
255: [0]=>
256: int(371)
257: [1]=>
258: string(3) "
259: "
260: [2]=>
261: int(5)
262: }
263: [31]=>
264: array(3) {
265: [0]=>
266: int(303)
267: [1]=>
268: string(4) "else"
269: [2]=>
270: int(6)
271: }
272: [32]=>
273: array(3) {
274: [0]=>
275: int(371)
276: [1]=>
277: string(5) "
278: "
279: [2]=>
280: int(6)
281: }
282: [33]=>
283: array(3) {
284: [0]=>
285: int(336)
286: [1]=>
287: string(6) "return"
288: [2]=>
289: int(7)
290: }
291: [34]=>
292: array(3) {
293: [0]=>
294: int(371)
295: [1]=>
296: string(1) " "
297: [2]=>
298: int(7)
299: }
300: [35]=>
301: array(3) {
302: [0]=>
303: int(305)
304: [1]=>
305: string(1) "1"
306: [2]=>
307: int(7)
308: }
309: [36]=>
310: string(1) "/"
311: [37]=>
312: array(3) {
313: [0]=>
314: int(309)
315: [1]=>
316: string(2) "$x"
317: [2]=>
318: int(7)
319: }
320: [38]=>
321: string(1) ";"
322: [39]=>
323: array(3) {
324: [0]=>
325: int(371)
326: [1]=>
327: string(1) "
328: "
329: [2]=>
330: int(7)
331: }
332: [40]=>
333: string(1) "}"
334: [41]=>
335: array(3) {
336: [0]=>
337: int(371)
338: [1]=>
339: string(1) "
340: "
341: [2]=>
342: int(8)
343: }
344: [42]=>
345: array(3) {
346: [0]=>
347: int(337)
348: [1]=>
349: string(3) "try"
350: [2]=>
351: int(9)
352: }
353: [43]=>
354: array(3) {
355: [0]=>
356: int(371)
357: [1]=>
358: string(1) " "
359: [2]=>
360: int(9)
361: }
362: [44]=>
363: string(1) "{"
364: [45]=>
365: array(3) {
366: [0]=>
367: int(371)
368: [1]=>
369: string(3) "
370: "
371: [2]=>
372: int(9)
373: }
374: [46]=>
375: array(3) {
376: [0]=>
377: int(316)
378: [1]=>
379: string(4) "echo"
380: [2]=>
381: int(10)
382: }
383: [47]=>
384: array(3) {
385: [0]=>
386: int(371)
387: [1]=>
388: string(1) " "
389: [2]=>
390: int(10)
391: }
392: [48]=>
393: array(3) {
394: [0]=>
395: int(307)
396: [1]=>
397: string(7) "inverse"
398: [2]=>
399: int(10)
400: }
401: [49]=>
402: string(1) "("
403: [50]=>
404: array(3) {
405: [0]=>
406: int(305)
407: [1]=>
408: string(1) "0"
409: [2]=>
410: int(10)
411: }
412: [51]=>
413: string(1) ")"
414: [52]=>
415: string(1) ";"
416: [53]=>
417: array(3) {
418: [0]=>
419: int(371)
420: [1]=>
421: string(3) "
422: "
423: [2]=>
424: int(10)
425: }
426: [54]=>
427: array(3) {
428: [0]=>
429: int(316)
430: [1]=>
431: string(4) "echo"
432: [2]=>
433: int(11)
434: }
435: [55]=>
436: array(3) {
437: [0]=>
438: int(371)
439: [1]=>
440: string(1) " "
441: [2]=>
442: int(11)
443: }
444: [56]=>
445: array(3) {
446: [0]=>
447: int(307)
448: [1]=>
449: string(7) "inverse"
450: [2]=>
451: int(11)
452: }
453: [57]=>
454: string(1) "("
455: [58]=>
456: array(3) {
457: [0]=>
458: int(305)
459: [1]=>
460: string(1) "5"
461: [2]=>
462: int(11)
463: }
464: [59]=>
465: string(1) ")"
466: [60]=>
467: string(1) ";"
468: [61]=>
469: array(3) {
470: [0]=>
471: int(371)
472: [1]=>
473: string(1) "
474: "
475: [2]=>
476: int(11)
477: }
478: [62]=>
479: string(1) "}"
480: [63]=>
481: array(3) {
482: [0]=>
483: int(371)
484: [1]=>
485: string(1) " "
486: [2]=>
487: int(12)
488: }
489: [64]=>
490: array(3) {
491: [0]=>
492: int(338)
493: [1]=>
494: string(5) "catch"
495: [2]=>
496: int(12)
497: }
498: [65]=>
499: string(1) "("
500: [66]=>
501: array(3) {
502: [0]=>
503: int(307)
504: [1]=>
505: string(9) "Exception"
506: [2]=>
507: int(12)
508: }
509: [67]=>
510: array(3) {
511: [0]=>
512: int(371)
513: [1]=>
514: string(1) " "
515: [2]=>
516: int(12)
517: }
518: [68]=>
519: array(3) {
520: [0]=>
521: int(309)
522: [1]=>
523: string(2) "$e"
524: [2]=>
525: int(12)
526: }
527: [69]=>
528: string(1) ")"
529: [70]=>
530: array(3) {
531: [0]=>
532: int(371)
533: [1]=>
534: string(1) " "
535: [2]=>
536: int(12)
537: }
538: [71]=>
539: string(1) "{"
540: [72]=>
541: array(3) {
542: [0]=>
543: int(371)
544: [1]=>
545: string(5) "
546: "
547: [2]=>
548: int(12)
549: }
550: [73]=>
551: array(3) {
552: [0]=>
553: int(316)
554: [1]=>
555: string(4) "echo"
556: [2]=>
557: int(13)
558: }
559: [74]=>
560: array(3) {
561: [0]=>
562: int(371)
563: [1]=>
564: string(1) " "
565: [2]=>
566: int(13)
567: }
568: [75]=>
569: array(3) {
570: [0]=>
571: int(315)
572: [1]=>
573: string(19) ""caught exception:""
574: [2]=>
575: int(13)
576: }
577: [76]=>
578: string(1) ";"
579: [77]=>
580: array(3) {
581: [0]=>
582: int(371)
583: [1]=>
584: string(1) "
585: "
586: [2]=>
587: int(13)
588: }
589: [78]=>
590: string(1) "}"
591: [79]=>
592: array(3) {
593: [0]=>
594: int(371)
595: [1]=>
596: string(1) "
597: "
598: [2]=>
599: int(14)
600: }
601: [80]=>
602: array(3) {
603: [0]=>
604: int(370)
605: [1]=>
606: string(2) "?>"
607: [2]=>
608: int(15)
609: }
610: }
611: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>