/[pcre]/code/trunk/testdata/testinput11
ViewVC logotype

Contents of /code/trunk/testdata/testinput11

Parent Directory Parent Directory | Revision Log Revision Log


Revision 642 - (show annotations)
Thu Jul 28 18:59:40 2011 UTC (8 years ago) by ph10
File size: 9798 byte(s)
Error occurred while calculating annotation data.
Avoid false positive for infinite recursion by not checking conditionals at 
compile time, but add tests at runtime that also catch infinite mutual 
recursion.
1 /-- These tests are for the Perl >= 5.10 features that PCRE supports. --/
2
3 /\H\h\V\v/
4 X X\x0a
5 X\x09X\x0b
6 ** Failers
7 \xa0 X\x0a
8
9 /\H*\h+\V?\v{3,4}/
10 \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
11 \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
12 \x09\x20\xa0\x0a\x0b\x0c
13 ** Failers
14 \x09\x20\xa0\x0a\x0b
15
16 /\H{3,4}/
17 XY ABCDE
18 XY PQR ST
19
20 /.\h{3,4}./
21 XY AB PQRS
22
23 /\h*X\h?\H+Y\H?Z/
24 >XNNNYZ
25 > X NYQZ
26 ** Failers
27 >XYZ
28 > X NY Z
29
30 /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
31 >XY\x0aZ\x0aA\x0bNN\x0c
32 >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
33
34 /(foo)\Kbar/
35 foobar
36
37 /(foo)(\Kbar|baz)/
38 foobar
39 foobaz
40
41 /(foo\Kbar)baz/
42 foobarbaz
43
44 /abc\K|def\K/g+
45 Xabcdefghi
46
47 /ab\Kc|de\Kf/g+
48 Xabcdefghi
49
50 /(?=C)/g+
51 ABCDECBA
52
53 /^abc\K/+
54 abcdef
55 ** Failers
56 defabcxyz
57
58 /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
59 ababababbbabZXXXX
60
61 /(?<A>tom|bon)-\g{A}/
62 tom-tom
63 bon-bon
64
65 /(^(a|b\g{-1}))/
66 bacxxx
67
68 /(?|(abc)|(xyz))\1/
69 abcabc
70 xyzxyz
71 ** Failers
72 abcxyz
73 xyzabc
74
75 /(?|(abc)|(xyz))(?1)/
76 abcabc
77 xyzabc
78 ** Failers
79 xyzxyz
80
81 /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
82 XYabcdY
83
84 /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
85 XYabcdY
86
87 /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
88 XYabcdY
89
90 /(?'abc'\w+):\k<abc>{2}/
91 a:aaxyz
92 ab:ababxyz
93 ** Failers
94 a:axyz
95 ab:abxyz
96
97 /(?'abc'\w+):\g{abc}{2}/
98 a:aaxyz
99 ab:ababxyz
100 ** Failers
101 a:axyz
102 ab:abxyz
103
104 /^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
105 abd
106 ce
107
108 /^(a.)\g-1Z/
109 aXaXZ
110
111 /^(a.)\g{-1}Z/
112 aXaXZ
113
114 /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
115 abcd
116
117 /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
118 (?(DEFINE)
119 (?<NAME_PAT>[a-z]+)
120 (?<ADDRESS_PAT>\d+)
121 )/x
122 metcalfe 33
123
124 /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
125 1.2.3.4
126 131.111.10.206
127 10.0.0.0
128 ** Failers
129 10.6
130 455.3.4.5
131
132 /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
133 1.2.3.4
134 131.111.10.206
135 10.0.0.0
136 ** Failers
137 10.6
138 455.3.4.5
139
140 /^(\w++|\s++)*$/
141 now is the time for all good men to come to the aid of the party
142 *** Failers
143 this is not a line with only words and spaces!
144
145 /(\d++)(\w)/
146 12345a
147 *** Failers
148 12345+
149
150 /a++b/
151 aaab
152
153 /(a++b)/
154 aaab
155
156 /(a++)b/
157 aaab
158
159 /([^()]++|\([^()]*\))+/
160 ((abc(ade)ufh()()x
161
162 /\(([^()]++|\([^()]+\))+\)/
163 (abc)
164 (abc(def)xyz)
165 *** Failers
166 ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
167
168 /^([^()]|\((?1)*\))*$/
169 abc
170 a(b)c
171 a(b(c))d
172 *** Failers)
173 a(b(c)d
174
175 /^>abc>([^()]|\((?1)*\))*<xyz<$/
176 >abc>123<xyz<
177 >abc>1(2)3<xyz<
178 >abc>(1(2)3)<xyz<
179
180 /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
181 1221
182 Satanoscillatemymetallicsonatas
183 AmanaplanacanalPanama
184 AblewasIereIsawElba
185 *** Failers
186 Thequickbrownfox
187
188 /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
189 12
190 (((2+2)*-3)-7)
191 -12
192 *** Failers
193 ((2+2)*-3)-7)
194
195 /^(x(y|(?1){2})z)/
196 xyz
197 xxyzxyzz
198 *** Failers
199 xxyzz
200 xxyzxyzxyzz
201
202 /((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
203 <>
204 <abcd>
205 <abc <123> hij>
206 <abc <def> hij>
207 <abc<>def>
208 <abc<>
209 *** Failers
210 <abc
211
212 /^a+(*FAIL)/
213 aaaaaa
214
215 /a+b?c+(*FAIL)/
216 aaabccc
217
218 /a+b?(*PRUNE)c+(*FAIL)/
219 aaabccc
220
221 /a+b?(*COMMIT)c+(*FAIL)/
222 aaabccc
223
224 /a+b?(*SKIP)c+(*FAIL)/
225 aaabcccaaabccc
226
227 /^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
228 aaaxxxxxx
229 aaa++++++
230 bbbxxxxx
231 bbb+++++
232 cccxxxx
233 ccc++++
234 dddddddd
235
236 /^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
237 aaaxxxxxx
238 aaa++++++
239 bbbxxxxx
240 bbb+++++
241 cccxxxx
242 ccc++++
243 dddddddd
244
245 /a+b?(*THEN)c+(*FAIL)/
246 aaabccc
247
248 /(A (A|B(*ACCEPT)|C) D)(E)/x
249 AB
250 ABX
251 AADE
252 ACDE
253 ** Failers
254 AD
255
256 /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
257 1221
258 Satan, oscillate my metallic sonatas!
259 A man, a plan, a canal: Panama!
260 Able was I ere I saw Elba.
261 *** Failers
262 The quick brown fox
263
264 /^((.)(?1)\2|.)$/
265 a
266 aba
267 aabaa
268 abcdcba
269 pqaabaaqp
270 ablewasiereisawelba
271 rhubarb
272 the quick brown fox
273
274 /(a)(?<=b(?1))/
275 baz
276 ** Failers
277 caz
278
279 /(?<=b(?1))(a)/
280 zbaaz
281 ** Failers
282 aaa
283
284 /(?<X>a)(?<=b(?&X))/
285 baz
286
287 /^(?|(abc)|(def))\1/
288 abcabc
289 defdef
290 ** Failers
291 abcdef
292 defabc
293
294 /^(?|(abc)|(def))(?1)/
295 abcabc
296 defabc
297 ** Failers
298 defdef
299 abcdef
300
301 /(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/xJ
302 a\"aaaaa
303 b\"aaaaa
304 ** Failers
305 b\"11111
306
307 /(?:(?1)|B)(A(*F)|C)/
308 ABCD
309 CCD
310 ** Failers
311 CAD
312
313 /^(?:(?1)|B)(A(*F)|C)/
314 CCD
315 BCD
316 ** Failers
317 ABCD
318 CAD
319 BAD
320
321 /(?:(?1)|B)(A(*ACCEPT)XX|C)D/
322 AAD
323 ACD
324 BAD
325 BCD
326 BAX
327 ** Failers
328 ACX
329 ABC
330
331 /(?(DEFINE)(A))B(?1)C/
332 BAC
333
334 /(?(DEFINE)((A)\2))B(?1)C/
335 BAAC
336
337 /(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
338 (ab(cd)ef)
339
340 /^(?!a(*SKIP)b)/
341 ac
342
343 /^(?=a(*SKIP)b|ac)/
344 ** Failers
345 ac
346
347 /^(?=a(*THEN)b|ac)/
348 ac
349
350 /^(?=a(*PRUNE)b)/
351 ab
352 ** Failers
353 ac
354
355 /^(?=a(*ACCEPT)b)/
356 ac
357
358 /^(?(?!a(*SKIP)b))/
359 ac
360
361 /(?>a\Kb)/
362 ab
363
364 /((?>a\Kb))/
365 ab
366
367 /(a\Kb)/
368 ab
369
370 /^a\Kcz|ac/
371 ac
372
373 /(?>a\Kbz|ab)/
374 ab
375
376 /^(?&t)(?(DEFINE)(?<t>a\Kb))$/
377 ab
378
379 /^([^()]|\((?1)*\))*$/
380 a(b)c
381 a(b(c)d)e
382
383 /(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
384 0
385 00
386 0000
387
388 /(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
389 0
390 00
391 0000
392
393 /--- This one does fail, as expected, in Perl. It needs the complex item at the
394 end of the pattern. A single letter instead of (B|D) makes it not fail,
395 which I think is a Perl bug. --- /
396
397 /A(*COMMIT)(B|D)/
398 ACABX
399
400 /--- Check the use of names for failure ---/
401
402 /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/K
403 ** Failers
404 AC
405 CB
406
407 /--- Force no study, otherwise mark is not seen. The studied version is in
408 test 2 because it isn't Perl-compatible. ---/
409
410 /(*MARK:A)(*SKIP:B)(C|X)/KSS
411 C
412 D
413
414 /^(A(*THEN:A)B|C(*THEN:B)D)/K
415 ** Failers
416 CB
417
418 /^(?:A(*THEN:A)B|C(*THEN:B)D)/K
419 CB
420
421 /^(?>A(*THEN:A)B|C(*THEN:B)D)/K
422 CB
423
424 /--- This should succeed, as the skip causes bump to offset 1 (the mark). Note
425 that we have to have something complicated such as (B|Z) at the end because,
426 for Perl, a simple character somehow causes an unwanted optimization to mess
427 with the handling of backtracking verbs. ---/
428
429 /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/xK
430 AAAC
431
432 /--- Test skipping over a non-matching mark. ---/
433
434 /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/xK
435 AAAC
436
437 /--- Check shorthand for MARK ---/
438
439 /A(*:A)A+(*SKIP:A)(B|Z) | AC/xK
440 AAAC
441
442 /--- Don't loop! Force no study, otherwise mark is not seen. ---/
443
444 /(*:A)A+(*SKIP:A)(B|Z)/KSS
445 AAAC
446
447 /--- This should succeed, as a non-existent skip name disables the skip ---/
448
449 /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/xK
450 AAAC
451
452 /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/xK
453 AAAC
454
455 /--- We use something more complicated than individual letters here, because
456 that causes different behaviour in Perl. Perhaps it disables some optimization;
457 anyway, the result now matches PCRE in that no tag is passed back for the
458 failures. ---/
459
460 /(A|P)(*:A)(B|P) | (X|P)(X|P)(*:B)(Y|P)/xK
461 AABC
462 XXYZ
463 ** Failers
464 XAQQ
465 XAQQXZZ
466 AXQQQ
467 AXXQQQ
468
469 /--- COMMIT at the start of a pattern should act like an anchor. Again,
470 however, we need the complication for Perl. ---/
471
472 /(*COMMIT)(A|P)(B|P)(C|P)/
473 ABCDEFG
474 ** Failers
475 DEFGABC
476
477 /--- COMMIT inside an atomic group can't stop backtracking over the group. ---/
478
479 /(\w+)(?>b(*COMMIT))\w{2}/
480 abbb
481
482 /(\w+)b(*COMMIT)\w{2}/
483 abbb
484
485 /--- Check opening parens in comment when seeking forward reference. ---/
486
487 /(?&t)(?#()(?(DEFINE)(?<t>a))/
488 bac
489
490 /--- COMMIT should override THEN ---/
491
492 /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
493 yes
494
495 /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
496 yes
497
498 /^((yes|no)(*THEN)(*F))?/
499 yes
500
501 /b?(*SKIP)c/
502 bc
503 abc
504
505 /(*SKIP)bc/
506 a
507
508 /(*SKIP)b/
509 a
510
511 /(?P<abn>(?P=abn)xxx|)+/
512 xxx
513
514 /(?i:([^b]))(?1)/
515 aa
516 aA
517 ** Failers
518 ab
519 aB
520 Ba
521 ba
522
523 /^(?&t)*+(?(DEFINE)(?<t>a))\w$/
524 aaaaaaX
525 ** Failers
526 aaaaaa
527
528 /^(?&t)*(?(DEFINE)(?<t>a))\w$/
529 aaaaaaX
530 aaaaaa
531
532 /^(a)*+(\w)/
533 aaaaX
534 YZ
535 ** Failers
536 aaaa
537
538 /^(?:a)*+(\w)/
539 aaaaX
540 YZ
541 ** Failers
542 aaaa
543
544 /^(a)++(\w)/
545 aaaaX
546 ** Failers
547 aaaa
548 YZ
549
550 /^(?:a)++(\w)/
551 aaaaX
552 ** Failers
553 aaaa
554 YZ
555
556 /^(a)?+(\w)/
557 aaaaX
558 YZ
559
560 /^(?:a)?+(\w)/
561 aaaaX
562 YZ
563
564 /^(a){2,}+(\w)/
565 aaaaX
566 ** Failers
567 aaa
568 YZ
569
570 /^(?:a){2,}+(\w)/
571 aaaaX
572 ** Failers
573 aaa
574 YZ
575
576 /(a|)*(?1)b/
577 b
578 ab
579 aab
580
581 /(a)++(?1)b/
582 ** Failers
583 ab
584 aab
585
586 /(a)*+(?1)b/
587 ** Failers
588 ab
589 aab
590
591 /(?1)(?:(b)){0}/
592 b
593
594 /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
595 foo(bar(baz)+baz(bop))
596
597 /(A (A|B(*ACCEPT)|C) D)(E)/x
598 AB
599
600 /\A.*?(?:a|b(*THEN)c)/
601 ba
602
603 /\A.*?(?:a|bc)/
604 ba
605
606 /\A.*?(a|b(*THEN)c)/
607 ba
608
609 /\A.*?(a|bc)/
610 ba
611
612 /\A.*?(?:a|b(*THEN)c)++/
613 ba
614
615 /\A.*?(?:a|bc)++/
616 ba
617
618 /\A.*?(a|b(*THEN)c)++/
619 ba
620
621 /\A.*?(a|bc)++/
622 ba
623
624 /\A.*?(?:a|b(*THEN)c|d)/
625 ba
626
627 /\A.*?(?:a|bc|d)/
628 ba
629
630 /(?:(b))++/
631 beetle
632
633 /(?(?=(a(*ACCEPT)z))a)/
634 a
635
636 /^(a)(?1)+ab/
637 aaaab
638
639 /^(a)(?1)++ab/
640 aaaab
641
642 /^(?=a(*:M))aZ/K
643 aZbc
644
645 /^(?!(*:M)b)aZ/K
646 aZbc
647
648 /(?(DEFINE)(a))?b(?1)/
649 backgammon
650
651 /^\N+/
652 abc\ndef
653
654 /^\N{1,}/
655 abc\ndef
656
657 /(?(R)a+|(?R)b)/
658 aaaabcde
659
660 /(?(R)a+|((?R))b)/
661 aaaabcde
662
663 /((?(R)a+|(?1)b))/
664 aaaabcde
665
666 /((?(R1)a+|(?1)b))/
667 aaaabcde
668
669 /-- End of testinput11 --/

  ViewVC Help
Powered by ViewVC 1.1.5