X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/b25a103638bc5111446c1e65a21db00a6e13acc1..3238b147ebaf6cfb04181176f9b1999d8dcfa7d9:/t/re/re_tests diff --git a/t/re/re_tests b/t/re/re_tests index 9da8491..5033060 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -5,7 +5,7 @@ # could not go in this file, and were farmed out to other .t's, where they # remain # -# pat string y/n/etc expr expected-expr skip-reason +# pat string y/n/etc expr expected-expr skip-reason comment __END__ abc abc y $& abc abc abc y $-[0] 0 @@ -108,7 +108,7 @@ a[b-d]e ace y $& ace a[b-d] aac y $& ac a[-b] a- y $& a- a[b-] a- y $& a- -a[b-a] - c - Invalid [] range \"b-a\" +a[b-a] - c - Invalid [] range a[]b - c - Unmatched [ a[ - c - Unmatched [ a] a] y $& a] @@ -352,7 +352,7 @@ a[-]?c ac y $& ac 'a[b-d]'i AAC y $& AC 'a[-b]'i A- y $& A- 'a[b-]'i A- y $& A- -'a[b-a]'i - c - Invalid [] range \"b-a\" +'a[b-a]'i - c - Invalid [] range 'a[]b'i - c - Unmatched [ 'a['i - c - Unmatched [ 'a]'i A] y $& A] @@ -582,8 +582,8 @@ x(~~)*(?:(?:F)?)? x~~ y - - ^(\(+)?blah(?(1)(\)))$ blah y ($2) () ^(\(+)?blah(?(1)(\)))$ blah) n - - ^(\(+)?blah(?(1)(\)))$ (blah n - - -(?(1?)a|b) a c - Switch condition not recognized -(?(1)a|b|c) a c - Switch (?(condition)... contains too many branches +(?(1?)a|b) - c - Switch condition not recognized +(?(1)a|b|c) - c - Switch (?(condition)... contains too many branches (?(?{0})a|b) a n - - (?(?{0})b|a) a y $& a (?(?{1})b|a) a n - - @@ -592,6 +592,10 @@ x(~~)*(?:(?:F)?)? x~~ y - - (?(?!a)b|a) a y $& a (?(?=a)b|a) a n - - (?(?=a)a|b) a y $& a +(?(?!\x{100})\x{100}|b) \x{100} n - - +(?(?!\x{100})b|\x{100}) \x{100} y $& \x{100} +(?(?=\x{100})b|\x{100}) \x{100} n - - +(?(?=\x{100})\x{100}|b) \x{100} y $& \x{100} (?=(a+?))(\1ab) aaab y $2 aab ^(?=(a+?))\1ab aaab n - - (\w+:)+ one: y $1 one: @@ -609,6 +613,8 @@ $(?<=^(a)) a y $1 a ^[^bcd]*(c+) aexycd y $1 c (?{$a=2})a*aa(?{local$a=$a+1})k*c(?{$b=$a}) yaaxxaaaacd y $b 3 (?{$a=2})(a(?{local$a=$a+1}))*aak*c(?{$b=$a}) yaaxxaaaacd y $b 4 +# [perl #117917] +^(a(?{ "x" =~ m{x}})b)(??{ $1 }) abab y $& abab (>a+)ab aaab n - - (?>a+)b aaab y - - ([[:]+) a:[b]: y $1 :[ @@ -617,8 +623,7 @@ $(?<=^(a)) a y $1 a [a[:xyz: - c - Unmatched [ [a[:xyz:] - c - POSIX class [:xyz:] unknown [a[:]b[:c] abc y $& abc -([a[:xyz:]b]+) pbaq c - POSIX class [:xyz:] unknown -[a[:]b[:c] abc y $& abc +([a[:xyz:]b]+) - c - POSIX class [:xyz:] unknown ([[:alpha:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd ([[:alnum:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy ([[:ascii:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__-- ${nulnul} @@ -635,6 +640,7 @@ $(?<=^(a)) a y $1 a ([[:^alpha:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 01 ((?a)[[:^alnum:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 __-- ${nulnul}${ffff} ([[:^ascii:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ${ffff} +([:[:^ascii:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ${ffff} RT #120799 ([[:^cntrl:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__-- ([[:^digit:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd ([[:^lower:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 AB @@ -877,12 +883,18 @@ foo.bart foo.bart y - - .[X](.+)+[X][X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - - .[X][X](.+)+[X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - - tt+$ xxxtt y - - -([a-\d]+) za-9z y $1 a-9 -([\d-z]+) a0-za y $1 0-z -([\d-\s]+) a0- z y $1 0- -([a-[:digit:]]+) za-9z y $1 a-9 -([[:digit:]-z]+) =0-z= y $1 0-z -([[:digit:]-[:alpha:]]+) =0-z= y $1 0-z +([a-\d]+) za-9z Sy $1 a-9 +([a-\d]+) - sc - False [] range +([\d-z]+) a0-za Sy $1 0-z +([\d-z]+) - sc $1 False [] range +([\d-\s]+) a0- z Sy $1 0- +([\d-\s]+) - sc $1 False [] range +([a-[:digit:]]+) za-9z Sy $1 a-9 +([a-[:digit:]]+) - sc - False [] range +([[:digit:]-z]+) =0-z= Sy $1 0-z +([[:digit:]-z]+) - sc c False [] range +([[:digit:]-[:alpha:]]+) =0-z= Sy $1 0-z +([[:digit:]-[:alpha:]]+) - sc - False [] range \GX.*X aaaXbX n - - (\d+\.\d+) 3.1415926 y $1 3.1415926 (\ba.{0,10}br) have a web browser y $1 a web br @@ -997,8 +1009,8 @@ a(b)?? abc y <$1> <> # undef [perl #16773] ^.{2,3}?((?:b|a|r)+?)\1\z foobarbar y $1 bar ^(?:f|o|b){2,3}?((?:b|a|r)+?)\1\z foobarbar y $1 bar .*a(?!(b|cd)*e).*f ......abef n - - # [perl #23030] -x(?# x c - Sequence (?#... not terminated -:x(?#: x c - Sequence (?#... not terminated +x(?# - c - Sequence (?#... not terminated +:x(?#: - c - Sequence (?#... not terminated (WORDS|WORD)S WORDS y $1 WORD (X.|WORDS|X.|WORD)S WORDS y $1 WORD (WORDS|WORLD|WORD)S WORDS y $1 WORD @@ -1083,9 +1095,9 @@ X(?<=foo.)[YZ] ..XfooXY.. y pos 8 (?Pfoo|bar|baz)(?P[ew]+) snofooewa yM $+{m} ew miniperl cannot load Tie::Hash::NamedCapture (?Pfoo)|(?Pbar)|(?Pbaz) snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture (?Pfoo)(??{ $+{n} }) snofooefoofoowaa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture -(?P<=n>foo|bar|baz) snofooewa c - Group name must start with a non-digit word character -(?Pfoo|bar|baz) snofooewa c - Group name must start with a non-digit word character -(?PXfoo|bar|baz) snofooewa c - Sequence (?PX<...) not recognized +(?P<=n>foo|bar|baz) - c - Group name must start with a non-digit word character +(?Pfoo|bar|baz) - c - Group name must start with a non-digit word character +(?PXfoo|bar|baz) - c - Sequence (?PX<...) not recognized /(?'n'foo|bar|baz)/ snofooewa y $1 foo /(?'n'foo|bar|baz)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture /(?'n'foo|bar|baz)(?'m'[ew]+)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture @@ -1263,30 +1275,30 @@ a*(*F) aaaab n - - /(?<_>foo) \k<_>/ ..foo foo.. yM $+{_} foo miniperl cannot load Tie::Hash::NamedCapture /(?'_0_'foo) \k'_0_'/ ..foo foo.. yM $+{_0_} foo miniperl cannot load Tie::Hash::NamedCapture /(?<_0_>foo) \k<_0_>/ ..foo foo.. yM $+{_0_} foo miniperl cannot load Tie::Hash::NamedCapture -/(?'0'foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?<0>foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?'12'foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?<12>foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?'1a'foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?<1a>foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?''foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/(?<>foo) bar/ ..foo bar.. c - Group name must start with a non-digit word character -/foo \k'n'/ foo foo c - Reference to nonexistent named group -/foo \k/ foo foo c - Reference to nonexistent named group -/foo \k'a1'/ foo foo c - Reference to nonexistent named group -/foo \k/ foo foo c - Reference to nonexistent named group -/foo \k'_'/ foo foo c - Reference to nonexistent named group -/foo \k<_>/ foo foo c - Reference to nonexistent named group -/foo \k'_0_'/ foo foo c - Reference to nonexistent named group -/foo \k<_0_>/ foo foo c - Reference to nonexistent named group -/foo \k'0'/ foo foo c - Group name must start with a non-digit word character -/foo \k<0>/ foo foo c - Group name must start with a non-digit word character -/foo \k'12'/ foo foo c - Group name must start with a non-digit word character -/foo \k<12>/ foo foo c - Group name must start with a non-digit word character -/foo \k'1a'/ foo foo c - Group name must start with a non-digit word character -/foo \k<1a>/ foo foo c - Group name must start with a non-digit word character -/foo \k''/ foo foo c - Group name must start with a non-digit word character -/foo \k<>/ foo foo c - Group name must start with a non-digit word character +/(?'0'foo) bar/ - c - Group name must start with a non-digit word character +/(?<0>foo) bar/ - c - Group name must start with a non-digit word character +/(?'12'foo) bar/ - c - Group name must start with a non-digit word character +/(?<12>foo) bar/ - c - Group name must start with a non-digit word character +/(?'1a'foo) bar/ - c - Group name must start with a non-digit word character +/(?<1a>foo) bar/ - c - Group name must start with a non-digit word character +/(?''foo) bar/ - c - Group name must start with a non-digit word character +/(?<>foo) bar/ - c - Group name must start with a non-digit word character +/foo \k'n'/ - c - Reference to nonexistent named group +/foo \k/ - c - Reference to nonexistent named group +/foo \k'a1'/ - c - Reference to nonexistent named group +/foo \k/ - c - Reference to nonexistent named group +/foo \k'_'/ - c - Reference to nonexistent named group +/foo \k<_>/ - c - Reference to nonexistent named group +/foo \k'_0_'/ - c - Reference to nonexistent named group +/foo \k<_0_>/ - c - Reference to nonexistent named group +/foo \k'0'/ - c - Group name must start with a non-digit word character +/foo \k<0>/ - c - Group name must start with a non-digit word character +/foo \k'12'/ - c - Group name must start with a non-digit word character +/foo \k<12>/ - c - Group name must start with a non-digit word character +/foo \k'1a'/ - c - Group name must start with a non-digit word character +/foo \k<1a>/ - c - Group name must start with a non-digit word character +/foo \k''/ - c - Group name must start with a non-digit word character +/foo \k<>/ - c - Group name must start with a non-digit word character /(?as) (\w+) \k (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie # \g{...} with a name as the argument @@ -1435,7 +1447,8 @@ abc\N abc\n n # and bypasses the lexer. /\N{U+}/ - c - Invalid hexadecimal number # Below currently gives a misleading message -/[\N{U+}]/ - c - Unmatched +/[\N{U+}]/ - Sc - Unmatched +/[\N{U+}]/ - sc - Syntax error in (?[...]) /abc\N{def/ - c - Missing right brace /\N{U+4AG3}/ - c - Illegal hexadecimal digit /[\N{U+4AG3}]/ - c - Illegal hexadecimal digit @@ -1477,20 +1490,64 @@ abc\N{def - c - \\N{NAME} must be resolved by the lexer [a\o{1000}] \x{200} y $& \x{200} # The below were inserting a NULL -\87 87 y $& 87 -a\87 a87 y $& a87 -a\97 a97 y $& a97 - +\87 87 c - Reference to nonexistent group in regex +a\87 a87 c - Reference to nonexistent group in regex +a\97 a97 c - Reference to nonexistent group in regex + +# avoid problems with 32-bit signed integer overflow + +(.)\g2147483648} x c - Reference to nonexistent group in regex +(.)\g2147483649} x c - Reference to nonexistent group in regex +(.)\g2147483650} x c - Reference to nonexistent group in regex +(.)\g4294967296} x c - Reference to nonexistent group in regex +(.)\g4294967297} x c - Reference to nonexistent group in regex +(.)\g4294967298} x c - Reference to nonexistent group in regex +a(.)\g2147483648} x c - Reference to nonexistent group in regex +a(.)\g2147483649} x c - Reference to nonexistent group in regex +a(.)\g2147483650} x c - Reference to nonexistent group in regex +a(.)\g4294967296} x c - Reference to nonexistent group in regex +a(.)\g4294967297} x c - Reference to nonexistent group in regex +a(.)\g4294967298} x c - Reference to nonexistent group in regex + +(.)\g{2147483648} x c - Reference to nonexistent group in regex +(.)\g{2147483649} x c - Reference to nonexistent group in regex +(.)\g{2147483650} x c - Reference to nonexistent group in regex +(.)\g{4294967296} x c - Reference to nonexistent group in regex +(.)\g{4294967297} x c - Reference to nonexistent group in regex +(.)\g{4294967298} x c - Reference to nonexistent group in regex +a(.)\g{2147483648} x c - Reference to nonexistent group in regex +a(.)\g{2147483649} x c - Reference to nonexistent group in regex +a(.)\g{2147483650} x c - Reference to nonexistent group in regex +a(.)\g{4294967296} x c - Reference to nonexistent group in regex +a(.)\g{4294967297} x c - Reference to nonexistent group in regex +a(.)\g{4294967298} x c - Reference to nonexistent group in regex + +(.)\2147483648 b\o{214}7483648 y $1 b +(.)\2147483649 b\o{214}7483649 y $1 b +(.)\2147483650 b\o{214}7483650 y $1 b +(.)\4294967296 b\o{42}94967296 y $1 b +(.)\4294967297 b\o{42}94967297 y $1 b +(.)\4294967298 b\o{42}94967298 y $1 b +a(.)\2147483648 ab\o{214}7483648 y $1 b +a(.)\2147483649 ab\o{214}7483649 y $1 b +a(.)\2147483650 ab\o{214}7483650 y $1 b +a(.)\4294967296 ab\o{42}94967296 y $1 b +a(.)\4294967297 ab\o{42}94967297 y $1 b +a(.)\4294967298 ab\o{42}94967298 y $1 b # The below was inserting a NULL into the character class. -[\8\9] \000 n - - -[\8\9] 8 y $& 8 -[\8\9] 9 y $& 9 +[\8\9] \000 Sn - - +[\8\9] - sc $& Unrecognized escape \\8 in character class +[\8\9] 8 Sy $& 8 +[\8\9] 9 Sy $& 9 # Verify that reads 1-3 octal digits, and that \_ works in char class -[\0] \000 y $& \000 -[\07] \007 y $& \007 -[\07] 7\000 n - - +[\0] \000 Sy $& \000 +[\0] - sc - Need exactly 3 octal digits +[\07] \007 Sy $& \007 +[\07] - sc - Need exactly 3 octal digits +[\07] 7\000 Sn - - +[\07] - sc - Need exactly 3 octal digits [\006] \006 y $& \006 [\006] 6\000 n - - [\0005] \0005 y $& \000 @@ -1532,7 +1589,7 @@ a\97 a97 y $& a97 # Normally 1E9E generates a multi-char fold, but not in inverted class; # See [perl #89750]. This makes sure that the simple fold gets generated # in that case, to DF. -/[^\x{1E9E}]/i \x{DF} n - - +/[^\x{1E9E}]/i \x{DF} Sn - - # RT #96354 /^.*\d\H/ X1 n - - @@ -1544,7 +1601,7 @@ a\97 a97 y $& a97 /^\p{L}/ \x{3400} y $& \x{3400} # RT #89774 -/[s\xDF]a/ui ssa y $& ssa +/[s\xDF]a/ui ssa Sy $& ssa /[s\xDF]a/ui sa y $& sa # RT #99928 @@ -1576,6 +1633,8 @@ ab[c\\\](??{"x"})]{3}d ab\\](d y - - /st/i \x{DF}\x{FB05} y $& \x{FB05} /ssst/i \x{DF}\x{FB05} y $& \x{DF}\x{FB05} +/[s]s/i \x{DF} n - - +/s[s]/i \x{DF} n - - # [perl #101970] /[[:lower:]]/i \x{100} y $& \x{100} @@ -1719,6 +1778,70 @@ ab[c\\\](??{"x"})]{3}d ab\\](d y - - # [ perl #114272] \Vn \xFFn/ y $& \xFFn +# These mostly exercize various paths in the optimizer /(?l:a?\w)/ b y $& b - +/(?l:a?\D)/ b y $& b +^_?[^\S_0-9]\w*\z \t y $& \t +m?^xy\?$? xy? y $& xy? +a?\X a\x{100} y $& a\x{100} +a?\R a\n y $& a\n +^a?\N$ a\n y $& a +\N?a \na y $& a +/\s?\s/l \t y $& \t +/\s?\d/l 3 y $& 3 +/\s?\S/l A y $& A + +# check we have the right utf8ness as we switch back and forth between +# patterns +^(\x{100}|a)(??{ qr/.?\xF7/d}) a_\xF7 y - - + +# [perl #118375] +/(a|(bc)){0,0}?xyz/ xyz y $& xyz +/( a | ( bc ) ) {0,0} ? xyz/x xyz y $& xyz + +/(a|(bc)){0,0}+xyz/ xyz y $& xyz +/( a | ( bc ) ) {0,0} + xyz/x xyz y $& xyz + +(A(*PRUNE)B|A(*PRUNE)C) AC n - - +(A(*PRUNE)B|A(*PRUNE)D|A(*PRUNE)C) AC n - - +(A(*PRUNE)B|A(*PRUNE)C|A(*PRUNE)D) AC n - - +((A(*PRUNE)B|A(*PRUNE)C)) AC n - - +((A(*PRUNE)B|A(*PRUNE)D|A(*PRUNE)C)) AC n - - +((A(*PRUNE)B|A(*PRUNE)C|A(*PRUNE)D)) AC n - - + +A+?(*THEN)BC AAABC y $& ABC +A+?(*PRUNE)BC AAABC y $& ABC +A+(*THEN)BC AAABC y $& AAABC +A+(*PRUNE)BC AAABC y $& AAABC +A+?(*THEN)BC(?{}) AAABC y $& ABC +A+?(*PRUNE)BC(?{}) AAABC y $& ABC +A+(*THEN)BC(?{}) AAABC y $& AAABC +A+(*PRUNE)BC(?{}) AAABC y $& AAABC +/[#]/ a#b y $& # +/[#]b/ a#b y $& #b +/[#]/x a#b y $& # +/[#]b/x a#b y $& #b +/[#](?{})/x a#b y $& # +/[#](??{'b'})/x a#b y $& #b +/(?#)(?{})b/ a#b y $& b +/(?#)(??{'b'})/ a#b y $& b +/[(?#](?{})b/ a#b y $& #b +/[(?#](??{'b'})/ a#b y $& #b +/(?#)(?{})b/x a#b y $& b +/(?#)(??{'b'})/x a#b y $& b + +# RT #119069: PCRE regression test: no segfault +^(?=(a)){0}b(?1) back y $& ba +# RT #119071: PCRE regression test: No warning of infinite regression +(?:(a(*SKIP)b)){0}(?:(?1)|ac) x n - - +# RT #119073: PCRE regression test: {0} => NOTHING optimization +(?1)(?:(b)){0} b y $& b +# RT #120041 +^A*\z y $& +/\N* /x ab y $& ab # Under /x was ignoring the '*' +/\N (?#comment) * /x ab y $& ab # likewise + +# RT #120600: Variable length lookbehind is not variable +(?a)(?(?=(?&W))(?<=(?&W)))(?&BB) aa y $& a # test repeated recursive patterns +# Keep these lines at the end of the file # vim: softtabstop=0 noexpandtab