#!./perl
#
# This is a home for regular expression tests that don't fit into
$| = 1;
print "1..1058\n";
BEGIN {
chdir 't' if -d 't';
}
eval 'use Config'; # Defaults assumed if this fails
$x = "abc\ndef\n";
$* = 1;
$* = 0;
$_ = '123';
if (/^([0-9][0-9]*)/) {print "ok 4\n";} else {print "not ok 4\n";}
$_ = 'aaabbbccc';
print "ok 13\n";
} else {
print "not ok 13\n";
}
print "ok 14\n";
} else {
print "not ok 14\n";
}
if (/a+b?c+/) {print "not ok 15\n";} else {print "ok 15\n";}
$_ = 'aaabccc';
if (/a+b?c+/) {print "ok 16\n";} else {print "not ok 16\n";}
if (/a*b+c*/) {print "ok 17\n";} else {print "not ok 17\n";}
$_ = 'aaaccc';
if (/a*b?c*/) {print "ok 18\n";} else {print "not ok 18\n";}
if (/a*b+c*/) {print "not ok 19\n";} else {print "ok 19\n";}
$_ = 'abcdef';
if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
$* = 1; # test 3 only tested the optimized version--this one is for real
if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";}
$* = 0;
?(.*)? && (print $1,"\n");
}
print "not ok 27\n";
exit;
}
print "ok 27\n";
'cde' =~ /[^ab]*/;
'xyz' =~ //;
$foo = '[^ab]*';
'cde' =~ /$foo/;
'xyz' =~ //;
$foo = '[^ab]*';
'cde' =~ /$foo/;
'xyz' =~ /$null/;
$_ = 'abcdefghi';
/def/; # optimized up to cmd
/cde/ + 0; # optimized only to spat
/[d][e][f]/; # not optimized
$_ = 'now is the {time for all} good men to come to.';
/ {([^}]*)}/;
$_ = 'xxx {3,4} yyy zzz';
print /( {3,4})/ ? "ok 35\n" : "not ok 35\n";
print /( {4,})/ ? "not ok 37\n" : "ok 37\n";
print /( {2,3}.)/ ? "ok 38\n" : "not ok 38\n";
print /(y{2,3}.)/ ? "ok 40\n" : "not ok 40\n";
print /x {3,4}/ ? "not ok 42\n" : "ok 42\n";
$_ = "now is the time for all good men to come to.";
@words = /(\w+)/g;
? "ok 44\n"
: "not ok 44\n";
@words = ();
while (/\w+/g) {
}
? "ok 45\n"
: "not ok 45\n";
@words = ();
pos = 0;
while (/to/g) {
}
? "ok 46\n"
pos $_ = 0;
@words = /to/g;
print join(':',@words) eq "to:to"
? "ok 47\n"
: "not ok 47 `@words'\n";
$pat1 = 'def';
$pat2 = '^def';
$pat3 = '.def.';
$pat4 = 'abc';
$pat5 = '^abc';
$pat6 = 'abc$';
$pat7 = 'ghi';
$pat8 = '\w*ghi';
$pat9 = 'ghi$';
for $iter (1..5) {
}
$xyz = 'xyz';
$x=/abc/g;
$x=/abc/g;
$x=/abc/g;
pos = 0;
pos = 0;
$x=/abc/g;
$x=/abc/g;
$_ .= '';
@x=/abc/g;
pos $_ = 2;
/\Gc/g;
$out = 1;
'abc' =~ m'a(?{ $out = 2 })b';
$out = 1;
'abc' =~ m'a(?{ $out = 3 })c';
$_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6';
@out = /(?<!foo)bar./g;
# Tests which depend on REG_INFTY
$reg_infty = defined $Config{reg_infty} ? $Config{reg_infty} : 32767;
$reg_infty_m = $reg_infty - 1; $reg_infty_p = $reg_infty + 1;
# As well as failing if the pattern matches do unexpected things, the
# next three tests will fail if you should have picked up a lower-than-
# default value for $reg_infty from Config.pm, but have not.
undef $@;
undef $@;
undef $@;
undef $@;
if $@ !~ m%^\QQuantifier in {,} bigger than%;
undef $@;
# Poke a couple more parse failures
$context = 'x' x 256;
# removed test
# Long Monsters
$test = 73;
for $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory
$a = 'a' x $l;
print "# length=$l\nnot " unless "ba$a=" =~ /a$a=/;
$test++;
print "not " if "b$a=" =~ /a$a=/;
$test++;
}
# 20000 nodes, each taking 3 words per string, and 1 per branch
'ax13876y25677mcb' => 0, # not b.
'ax13876y35677nbc' => 0, # Num too big
'ax13876y25677y21378obc' => 1,
'ax13876y25677y21378zbc' => 0, # Not followed by [k-o]
'ax13876y25677y21378y21378kbc' => 1,
'ax13876y25677y21378y21378kcb' => 0, # Not b.
'ax13876y25677y21378y21378y21378kbc' => 0, # 5 runs
);
print "# const-len `$_' not => $ans{$_}\nnot "
if $ans{$_} xor /a(?=([yx]($long_constant_len)){2,4}[k-o]).*b./o;
print "ok $test\n";
$test++;
if $ans{$_} xor /a(?=([yx]($long_var_len)){2,4}[k-o]).*b./o;
$test++;
}
sub matchit {
m/
(
\(
(?{ $c = 1 }) # Initialize
(?:
(?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
(?!
) # Fail: will unwind one iteration back
)
(?:
[^()]+ # Match a big chunk
(?=
[()]
) # Do not try to match subchunks
|
\(
(?{ ++$c })
|
\)
(?{ --$c })
)
)+ # This may not match with different subblocks
)
(?(?{ $c != 0 })
(?!
) # Fail
) # Otherwise the chunk 1 may succeed with $c>0
/xg;
}
@ans = ();
print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
$test++;
$test++;
$test++;
my $matched;
$test++;
$test++;
$test++;
$test++;
$blah = 12;
$test++;
$blah = 12;
} else {
}
$test++;
}
$blah = 12;
$test++;
$blah = 12;
$test++;
$x = 'banana';
$x =~ /.a/g;
$test++;
$test++;
sub f {
my $p = $_[0];
return $p;
}
$x =~ /.a/g;
$test++;
$x = $^R = 67;
$test++;
$x = $^R = 67;
$test++;
$x = $^R = 67;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$_ = 'xabcx';
/(?<=(?=a)..)((?=c)|.)/g;
$test++;
}
$_ = 'a';
/^|a|$/g;
$test++;
}
sub prefixify {
$v =~ s/\Q$a\E/$b/;
$test++;
}
$_ = 'var="foo"';
/(\")/;
$test++;
$b = 7;
/$a$a/;
$test++;
$c="$a";
/$a$a/;
$test++;
{
/$a$c$a/;
$test++;
local $lex_a = 2;
my $lex_a = 43;
my $lex_b = 17;
my $lex_c = 27;
$test++;
$test++;
$test++;
$match = eval { /$a$c$a/ };
print "not "
$test++;
}
{
local $lex_a = 2;
my $lex_a = 43;
my $lex_b = 17;
my $lex_c = 27;
$test++;
$test++;
$test++;
}
{
$c = 2;
$::c = 3;
'' =~ /(?{ $c = 4 })/;
}
$test++;
$test++;
sub must_warn_pat {
my $warn_pat = shift;
}
sub must_warn {
local %SIG;
$test++;
}
sub make_must_warn {
my $warn_pat = shift;
}
#&$for_future('q(a=[b]=) =~ /[x[=foo=]]/');
#&$for_future('q(a.[b].) =~ /[x[.foo.]]/');
# test if failure of patterns returns empty list
$_ = 'aaa';
@_ = /bbb/;
print "not " if @_;
$test++;
@_ = /bbb/g;
print "not " if @_;
$test++;
print "not " if @_;
$test++;
print "not " if @_;
$test++;
/a(?=.$)/;
$test++;
$test++;
print "not "
$test++;
/a(a)(a)/;
$test++;
$test++;
$test++;
$test++;
print "not "
$test++;
/.(a)(b)?(a)/;
$test++;
$test++;
$test++;
$test++;
print "not "
$test++;
/.(a)/;
$test++;
$test++;
$test++;
print "not "
$test++;
eval { $+[0] = 13; };
print "not "
if $@ !~ /^Modification of a read-only value attempted/;
$test++;
eval { $-[0] = 13; };
print "not "
if $@ !~ /^Modification of a read-only value attempted/;
$test++;
eval { @+ = (7, 6, 5); };
print "not "
if $@ !~ /^Modification of a read-only value attempted/;
$test++;
print "not "
if $@ !~ /^Modification of a read-only value attempted/;
$test++;
$test++;
$_ = 'aaa';
pos = 1;
@a = /\Ga/g;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$_ = $str;
$test++;
$test++;
$test++;
$_ = 'abcde|abcde';
$test++;
# List context:
$_ = 'abcde|abcde';
print "#'@res' '$_'\nnot "
$test++;
print "#'@res' '$_'\nnot "
"'' 'ab' 'cde|abcde' " .
"'' 'abc' 'de|abcde' " .
"'abcd' 'e|' 'abcde' " .
"'abcde|' 'ab' 'cde' " .
"'abcde|' 'abc' 'de'" ;
$test++;
#Some more \G anchor checks
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$_='123x123';
$test++;
# see if matching against temporaries (created via pp_helem()) is safe
print "$1\n";
$test++;
# See if $i work inside (?{}) in the presense of saved substrings and
# changing $_
@b = ();
$test++;
$test++;
}x;
"{{}" =~ $brackets;
$test++;
"something { long { and } hairy" =~ $brackets;
$test++;
$test++;
$_ = "a-a\nxbb";
pos=1;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
$test++;
# see if backtracking optimization works correctly
$test++;
$test++;
$test++;
$test++;
eval << 'EOE';
{
package S;
}
$test++;
# test result of match used as match (!)
$test++;
$test++;
$w = 0;
{
local $^W = 1;
$w = 1 if ("1\n" x 102) =~ /^\s*\n/m;
}
$test++;
# There's no \v but the vertical tabulator seems miraculously
# be 11 both in ASCII and EBCDIC.
false => "space" );
$test++;
$test++;
$test++;
# bugid 20001021.005 - this caused a SEGV
$test++;
# bugid 20000731.001
$test++;
$_ = "a\x{100}b";
if (/(.)(\C)(\C)(.)/) {
print "ok 232\n";
print "ok 233\n";
} else {
print "not ok 233\n";
}
print "ok 234\n";
} else {
print "not ok 234\n";
}
print "ok 235\n";
} else {
print "not ok 235\n";
}
print "ok 234\n";
} else {
print "not ok 234\n";
}
print "ok 235\n";
} else {
print "not ok 235\n";
}
} else {
for (234..235) {
}
}
print "ok 236\n";
} else {
print "not ok 236\n";
}
} else {
for (232..236) {
print "not ok $_\n";
}
}
$_ = "\x{100}";
if (/(\C)/g) {
print "ok 237\n";
# currently \C are still tagged as UTF-8
print "ok 238\n";
} else {
print "not ok 238\n";
}
print "ok 238\n";
} else {
print "not ok 238\n";
}
} else {
}
} else {
for (237..238) {
print "not ok $_\n";
}
}
if (/(\C)/g) {
print "ok 239\n";
# currently \C are still tagged as UTF-8
print "ok 240\n";
} else {
print "not ok 240\n";
}
print "ok 240\n";
} else {
print "not ok 240\n";
}
} else {
}
} else {
for (239..240) {
print "not ok $_\n";
}
}
{
# japhy -- added 03/03/2001
print "ok 241\n";
}
# The 242 and 243 go with the 244 and 245.
# The trick is that in EBCDIC the explicit numeric range should match
# (as also in non-EBCDIC) but the explicit alphabetic range should not match.
print "ok 242\n";
} else {
print "not ok 242\n";
}
print "ok 243\n";
} else {
print "not ok 243\n";
}
# In most places these tests would succeed since \x8e does not
# in most character sets match 'i' or 'j' nor would \xce match
# 'I' or 'J', but strictly speaking these tests are here for
# the good of EBCDIC, so let's test these only there.
if ("\x8e" !~ /[i-j]/) {
print "ok 244\n";
} else {
print "not ok 244\n";
}
if ("\xce" !~ /[I-J]/) {
print "ok 245\n";
} else {
print "not ok 245\n";
}
} else {
for (244..245) {
print "ok $_ # Skip: only in EBCDIC\n";
}
}
print "ok 246\n";
print "ok 247\n";
{
# bug id 20001008.001
my $test = 248;
my @x = ("stra\337e 138","stra\337e 138");
for (@x) {
$test++;
use utf8; # needed for the raw UTF-8
}
}
{
print "ok 250\n";
print "ok 251\n";
print "ok 252\n";
print "ok 253\n";
print "ok 254\n";
print "ok 255\n";
print "ok 256\n";
print "ok 257\n";
}
{
# the first half of 20001028.003
my ($Y) = $X =~ /(.*)/;
print "ok 258\n";
}
{
# 20001108.001
my $X = "Szab\x{f3},Bal\x{e1}zs";
my $Y = $X;
$Y =~ s/(B)/$1/ for 0..3;
print "ok 259\n";
}
{
# the second half of 20001028.003
my $X = '';
print "ok 260\n";
}
{
# 20000517.001
my $x = "\x{100}A";
$x =~ s/A/B/;
print "ok 261\n";
}
{
# bug id 20001230.002
print "ok 262\n";
print "ok 263\n";
}
SKIP: {
my $test = 264; # till 575
# This is far from complete testing, there are dozens of character
# classes in Unicode. The mixing of literals and \N{...} is
# intentional so that in non-Latin-1 places we test the native
# characters, not the Unicode code points.
my %s = (
"a" => 'Ll',
"\N{CYRILLIC SMALL LETTER A}" => 'Ll',
"A" => 'Lu',
"\N{GREEK CAPITAL LETTER ALPHA}" => 'Lu',
"\N{HIRAGANA LETTER SMALL A}" => 'Lo',
"\N{COMBINING GRAVE ACCENT}" => 'Mn',
"0" => 'Nd',
"\N{ARABIC-INDIC DIGIT ZERO}" => 'Nd',
"_" => 'N',
"!" => 'P',
" " => 'Zs',
"\0" => 'Cc',
);
print "# IsAlpha\n";
} else {
}
print "# IsAlnum\n";
} else {
}
print "# IsASCII\n";
} else {
} else {
}
}
print "# IsCntrl\n";
} else {
}
print "# IsBlank\n";
} else {
}
print "# IsDigit\n";
} else {
}
print "# IsGraph\n";
} else {
}
print "# IsLower\n";
} else {
}
print "# IsPrint\n";
} else {
}
print "# IsPunct\n";
} else {
}
print "# IsSpace\n";
} else {
}
print "# IsUpper\n";
} else {
}
print "# IsWord\n";
} else {
}
}
}
{
$_ = "abc\x{100}\x{200}\x{300}\x{380}\x{400}defg";
if (/(.\x{300})./) {
print "ok 576\n";
print "ok 577\n";
print "ok 578\n";
print "ok 579\n";
print "ok 580\n";
} else {
for (576..580) { print "not ok $_\n" }
}
}
{
# bug id 20010306.008
$a = "a\x{1234}";
# The original bug report had 'no utf8' here but that was irrelevant.
$a =~ m/\w/; # used to core dump
print "ok 581\n";
}
{
$test = 582;
# bugid 20010410.006
for my $rx (
'/(.*?)\{(.*?)\}/csg',
'/(.*?)\{(.*?)\}/cg',
'/(.*?)\{(.*?)\}/sg',
'/(.*?)\{(.*?)\}/g',
'/(.+?)\{(.+?)\}/csg',
)
{
$i = 0;
eval <<EOT;
while (eval \$input =~ $rx) {
print "# \\\$1 = '\$1' \\\$2 = '\$2'\n";
++\$i;
}
EOT
}
}
{
# from Robin Houston
my $x = "\x{10FFFD}";
$x =~ s/(.)/$1/g;
print "ok 587\n";
}
{
my $x = "\x7f";
print "ok 588\n";
print "ok 589\n";
print "not " if $x =~ /[\x{100}]/;
print "ok 590\n";
print "ok 591\n";
print "ok 592\n";
print "ok 593\n";
print "ok 594\n";
}
{
my $x = "\x80";
print "ok 595\n";
print "ok 596\n";
print "not " if $x =~ /[\x{100}]/;
print "ok 597\n";
print "ok 598\n";
print "ok 599\n";
print "ok 600\n";
print "ok 601\n";
}
{
my $x = "\xff";
print "ok 602\n";
print "ok 603\n";
print "not " if $x =~ /[\x{100}]/;
print "ok 604\n";
# the next two tests must be ignored on EBCDIC
print "ok 605\n";
print "ok 606\n";
print "ok 607\n";
print "ok 608\n";
}
{
my $x = "\x{100}";
print "ok 609\n";
print "ok 610\n";
print "ok 611\n";
print "ok 612\n";
print "ok 613\n";
print "ok 614\n";
print "ok 615\n";
}
{
# from japhy
my $w;
use warnings;
$w = "";
eval 'qr/(?c)/';
print "ok 616\n";
$w = "";
eval 'qr/(?-c)/';
print "ok 617\n";
$w = "";
eval 'qr/(?g)/';
print "ok 618\n";
$w = "";
eval 'qr/(?-g)/';
print "ok 619\n";
$w = "";
eval 'qr/(?o)/';
print "ok 620\n";
$w = "";
eval 'qr/(?-o)/';
print "ok 621\n";
# now test multi-error regexes
$w = "";
eval 'qr/(?g-o)/';
print "ok 622\n";
$w = "";
eval 'qr/(?g-c)/';
print "ok 623\n";
$w = "";
eval 'qr/(?o-cg)/'; # (?c) means (?g) error won't be thrown
print "ok 624\n";
$w = "";
eval 'qr/(?ogc)/';
print "ok 625\n";
}
# More Unicode "class" tests
{
print "ok 626\n";
print "ok 627\n";
print "ok 628\n";
print "ok 629\n";
print "ok 630\n";
}
$_ = "foo";
/f
o\r
o
\$
/x && print "ok 631\n";
/f
o
o
\$\r
/x && print "ok 632\n";
#test /o feature
sub test_o { $_[0] =~/$_[1]/o; return $1}
print "ok 633\n";
} else {
print "not ok 633\n";
}
print "ok 634\n";
} else {
print "not ok 634\n";
}
# 635..639: ID 20010619.003 (only the space character is
# supposed to be [:print:], not the whole isprint()).
print "not " if "\n" =~ /[[:print:]]/;
print "ok 635\n";
print "not " if "\t" =~ /[[:print:]]/;
print "ok 636\n";
# Amazingly vertical tabulator is the same in ASCII and EBCDIC.
print "not " if "\014" =~ /[[:print:]]/;
print "ok 637\n";
print "not " if "\r" =~ /[[:print:]]/;
print "ok 638\n";
print "ok 639\n";
##
## Test basic $^N usage outside of a regex
##
$x = "abcdef";
{
}
## test to see if $^N is automatically localized -- it should now
## have the value set in test 653
##
## Now test inside (?{...})
##
$T="ok 658\n";if ($x =~ /a([abcdefg]+)(?{$y=$^N})d/ and $y eq "bc"){print $T} else {print "not $T"};
{print $T} else {print "not $T"};
{print $T} else {print "not $T"};
# Test the Unicode script classes
print "ok 661\n";
print "ok 662\n";
print "ok 663\n";
print "ok 664\n";
# # singleton (not in a range, this test must be ignored on EBCDIC)
# print "not " unless chr(0xb5) =~ /\p{IsGreek}/ or ord("A") == 193;
# print "ok 665\n";
print "ok 665 # 0xb5 moved from Greek to Common with Unicode 4.0.1\n";
print "ok 666\n";
print "ok 667\n";
print "ok 668\n";
print "ok 669\n";
print "ok 670\n";
print "ok 671\n";
print "ok 672\n";
##
## Test [:cntrl:]...
##
## Should probably put in tests for all the POSIX stuff, but not sure how to
## guarantee a specific locale......
##
print "not ";
}
print "ok 673\n";
print "ok 674\n";
} else {
print "ok $_ # Skip: EBCDIC\n" for 673..674;
}
# With /s modifier UTF8 chars were interpreted as bytes
{
my $a = "Hello \x{263A} World";
print "ok 675\n";
}
@a = ("foo\nbar" =~ /./g);
@a = ("foo\nbar" =~ /\C/g);
@a = ("foo\n\x{100}bar" =~ /./g);
@a = ("foo\n\x{100}bar" =~ /\C/g);
{
# [ID 20010814.004] pos() doesn't work when using =~m// in list context
$_ = "ababacadaea";
$c = pos;
}
{
# [ID 20010407.006] matching utf8 return values from functions does not work
sub x {
"a\x{1234}";
}
my $x = x;
my $y;
$x =~ /(..)/; $y = $1;
print "ok 685\n";
x =~ /(..)/; $y = $1;
print "ok 686\n";
}
my $test = 687;
# Force scalar context on the patern match
$test++;
return $ok;
}
{
# Check that \x## works. 5.6.1 and 5.005_03 fail some of these.
$x = "\x4e" . "E";
$x = "\x4e" . "i";
$x = "\x4" . "j";
$x = "\x0" . "k";
$x = "\x0" . "x";
$x = "\x0" . "xa";
$x = "\x9" . "_b";
print "# and now again in [] ranges\n";
$x = "\x4e" . "E";
$x = "\x4e" . "i";
$x = "\x4" . "j";
$x = "\x0" . "k";
$x = "\x0" . "x";
$x = "\x0" . "xa";
$x = "\x9" . "_b";
}
{
# Check that \x{##} works. 5.6.1 fails quite a few of these.
$x = "\x9b";
$x = "\x9b" . "y";
$x = "\x9b" . "y";
$x = "\x9b" . "y";
$x = "\x0" . "y";
$x = "\x0" . "y";
$x = "\x9b" . "y";
print "# and now again in [] ranges\n";
$x = "\x9b";
$x = "\x9b" . "y";
$x = "\x9b" . "y";
$x = "\x9b" . "y";
$x = "\x0" . "y";
$x = "\x0" . "y";
$x = "\x9b" . "y";
}
{
# high bit bug -- japhy
my $x = "ab\200d";
print "ok 715\n";
}
print "# some Unicode properties\n";
{
# Dashes, underbars, case.
print "ok 716\n";
# Complement, leading and trailing whitespace.
print "ok 717\n";
# No ^In, dashes, case, dash, any intervening (word-break) whitespace.
# (well, newlines don't work...)
print "ok 718\n";
}
{
print "ok 719\n";
print "ok 720\n";
print "ok 721\n";
print "ok 722\n";
print "ok 723\n";
print "ok 724\n";
print "ok 725\n";
print "ok 726\n";
print "ok 727\n";
print "ok 728\n";
print "ok 729\n";
print "ok 730\n";
print "ok 731\n";
print "ok 732\n";
print "ok 733\n";
print "ok 734\n";
print "ok 735\n";
print "ok 736\n";
print "ok 737\n";
print "ok 738\n";
}
{
print "ok 739\n";
print "ok 740\n";
}
{
print "ok 741\n";
print "ok 742\n";
}
{
print "ok 743\n";
print "not " if "1" =~ /\p{L&}/;
print "ok 744\n";
}
{
print "ok 745\n";
print "ok 746\n";
}
{
print "ok 747\n";
}
{
# Script=, Block=, Category=
print "ok 748\n";
print "ok 749\n";
print "ok 750\n";
}
{
print "# the basic character classes and Unicode \n";
# 0100;LATIN CAPITAL LETTER A WITH MACRON;Lu;0;L;0041 0304;;;;N;LATIN CAPITAL LETTER A MACRON;;;0101;
print "ok 751\n";
# 0660;ARABIC-INDIC DIGIT ZERO;Nd;0;AN;;0;0;0;N;;;;;
print "ok 752\n";
# 1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;
print "ok 753\n";
}
{
print "# folding matches and Unicode\n";
print "ok 754\n";
print "ok 755\n";
print "ok 756\n";
print "ok 757\n";
print "ok 758\n";
print "ok 759\n";
print "ok 760\n";
print "ok 761\n";
print "ok 762\n";
print "ok 763\n";
print "ok 764\n";
print "ok 765\n";
print "ok 766\n";
print "ok 767\n";
print "ok 768\n";
print "ok 769\n";
print "ok 770\n";
print "ok 771\n";
print "ok 772\n";
print "ok 773\n";
}
{
print "# LATIN LETTER A WITH GRAVE\n";
print "# GREEK LETTER ALPHA WITH VRACHY\n";
print "# LATIN LETTER Y WITH DIAERESIS\n";
}
{
use warnings;
print "# GREEK CAPITAL LETTER SIGMA vs COMBINING GREEK PERISPOMENI\n";
# Before #13843 this was failing by matching falsely.
}
{
print "# \\X\n";
"ok 787\n" : "not ok 787 # $1\n";
"ok 788\n" : "not ok 788 # $1\n";
"ok 789\n" : "not ok 789 # $1\n";
"ok 790\n" : "not ok 790 # $1\n";
print "\N{LATIN CAPITAL LETTER E}!" =~ /^(\X)!/ &&
"ok 791\n" : "not ok 791 # $1\n";
print "\N{LATIN CAPITAL LETTER E}\N{COMBINING GRAVE ACCENT}!" =~
/^(\X)!/ &&
"ok 792\n" : "not ok 792 # $1\n";
}
{
print "#\\C and \\X\n";
}
{
print "# FINAL SIGMA\n";
}
{
print "# parlez-vous?\n";
print "fran\N{LATIN SMALL LETTER C}ais" =~
/fran.ais/ &&
"ok 813\n" : "not ok 813\n";
print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
/fran.ais/ &&
"ok 814\n" : "not ok 814\n";
print "fran\N{LATIN SMALL LETTER C}ais" =~
"ok 815\n" : "not ok 815\n";
print "franc\N{COMBINING CEDILLA}ais" =~
"ok 816\n" : "not ok 816\n";
print "fran\N{LATIN SMALL LETTER C}ais" =~
"ok 817\n" : "not ok 817\n";
print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
"ok 818\n" : "not ok 818\n";
print "franc\N{COMBINING CEDILLA}ais" =~
"ok 819\n" : "not ok 819\n";
print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
"ok 820\n" : "not ok 820\n";
print "franc\N{COMBINING CEDILLA}ais" =~
"ok 821\n" : "not ok 821\n";
print "fran\N{LATIN SMALL LETTER C}ais" =~
"ok 822\n" : "not ok 822\n";
print "fran\N{LATIN SMALL LETTER C}ais" =~
"ok 823\n" : "not ok 823\n";
print "fran\N{LATIN SMALL LETTER C WITH CEDILLA}ais" =~
"ok 824\n" : "not ok 824\n";
print "franc\N{COMBINING CEDILLA}ais" =~
"ok 825\n" : "not ok 825\n";
}
{
print "# Does lingering (and useless) UTF8 flag mess up /i matching?\n";
{
print "ok 826\n";
} else {
print "not ok 826\n";
}
}
{
print "ok 827\n";
} else {
print "not ok 827\n";
}
}
{
print "ok 828\n";
} else {
print "not ok 828\n";
}
}
}
{
print "# more SIGMAs\n";
"ok 829\n" : "not ok 829\n";
"ok 830\n" : "not ok 830\n";
"ok 831\n" : "not ok 831\n";
"ok 832\n" : "not ok 832\n";
"ok 833\n" : "not ok 833\n";
"ok 834\n" : "not ok 834\n";
}
{
print "# LATIN SMALL LETTER SHARP S\n";
print "\N{LATIN SMALL LETTER SHARP S}" =~
print "\N{LATIN SMALL LETTER SHARP S}" =~
print "\N{LATIN SMALL LETTER SHARP S}" =~
print "\N{LATIN SMALL LETTER SHARP S}" =~
print "ss" =~
print "SS" =~
print "ss" =~
print "SS" =~
"ok 843\n" : "not ok 843\n";
"ok 844\n" : "not ok 844\n";
}
{
print "# more whitespace: U+0085, U+2028, U+2029\n";
# U+0085 needs to be forced to be Unicode, the \x{100} does that.
print "<\x{100}\x{0085}>" =~ /<\x{100}\s>/ ? "ok 845\n" : "not ok 845\n";
print "<\x{2028}>" =~ /<\s>/ ? "ok 846\n" : "not ok 846\n";
print "<\x{2029}>" =~ /<\s>/ ? "ok 847\n" : "not ok 847\n";
}
{
print "# . with /s should work on characters, as opposed to bytes\n";
my $s = "\x{e4}\x{100}";
# This is not expected to match: the point is that
# neither should we get "Malformed UTF-8" warnings.
"not ok 848\n" : "ok 848\n";
my @c;
push @c, $1;
}
$r1 .= $1 . $2;
}
$r2 .= $1 . $2;
}
$r2 =~ s/\x{100}//;
}
{
print "# Unicode lookbehind\n";
print "A\x{100}B" =~ /(?<=A.)B/ ? "ok 851\n" : "not ok 851\n";
print "A\x{200}\x{300}B" =~ /(?<=A..)B/ ? "ok 852\n" : "not ok 852\n";
print "\x{400}AB" =~ /(?<=\x{400}.)B/ ? "ok 853\n" : "not ok 853\n";
print "\x{500\x{600}}B" =~ /(?<=\x{500}.)B/ ? "ok 854\n" : "not ok 854\n";
}
{
print "# UTF-8 hash keys and /\$/\n";
my $u = "a\x{100}";
my %u = ( $u => $u, $v => $v, $w => $w );
my $i = 855;
my $m1 = /^\w*$/ ? 1 : 0;
my $m2 = $u{$_}=~/^\w*$/ ? 1 : 0;
$i++;
}
}
{
print "# [ID 20020124.005]\n";
# Fixed by #14795.
my $i = 858;
"c" =~ /c/;
"x";
}ge;
"ok $i\n" : "not ok $i # debug: $x\n";
$i++;
}
}
{
print "# SEGV in s/// and UTF-8\n";
$s = "s#\x{100}" x 4;
$s =~ s/[^\w]/ /g;
}
{
print "# UTF-8 bug (maybe alreayd known?)\n";
my $u;
$u = "foo";
$u =~ s/./\x{100}/g;
$u = "foobar";
$u =~ s/[ao]/\x{100}/g;
$u =~ s/\x{100}/e/g;
}
{
print "# UTF-8 bug with s///\n";
my $c = "\x{100}";
my $test = 865;
my $subst;
for my $re (
"xx.*$c", "x.*$c$c", "$c.*xx", "$c$c.*x", "xx.*(?=$c)", "(?=$c).*xx",
) {
++$test;
++$test;
}
++$test;
++$test;
}
++$test;
++$test;
++$test;
++$test;
}
++$test;
++$test;
}
}
{
print "# qr/.../x\n";
my $test = 893;
my $R = qr/ A B C # D E/x;
$test++;
$test++;
$test++;
}
{
print "# illegal Unicode properties\n";
my $test = 896;
$test++;
$test++;
}
{
print "# [ID 20020412.005] wrong pmop flags checked when empty pattern\n";
# requires reuse of last successful pattern
my $test = 898;
$test =~ /\d/;
for (0 .. 1) {
my $match = ?? + 0;
} else {
}
++$test;
}
} else {
}
++$test;
}
print "# user-defined character properties\n";
sub InKana1 {
return <<'END';
3040 309F
}
sub InKana2 {
return <<'END';
}
sub InKana3 {
return <<'END';
}
sub InNotKana {
return <<'END';
}
$test = 901;
return <<EOF;
0061 007f
-0061
-0065
-0069
-006f
-0075
EOF
}
{
print "# [ID 20020630.002] utf8 regex only matches 32k\n";
$test = 911;
for ([ 'byte', "\x{ff}" ], [ 'utf8', "\x{1ff}" ]) {
++$test;
++$test;
}
}
}
$test = 923;
print(('goodfood' =~ $a ? '' : 'not '),
++$test;
++$test;
$x = "\x{3fe}";
$z=$y = "\317\276"; # $y is byte representation of $x
$a = qr/$x/;
++$test;
print(("a$a" =~ $x ? '' : 'not '),
++$test;
print(("a$x" =~ /^a$a\z/ ? '' : 'not '),
++$test;
print(("a$x" =~ /^a(??{$a})\z/ ? '' : 'not '),
++$test;
++$test;
print(("$x$x" =~ /^$x(??{$x})\z/ ? '' : 'not '),
++$test;
print(("$y$x" =~ /^$y(??{$x})\z/ ? '' : 'not '),
++$test;
print(("$y$x" !~ /^$y(??{$y})\z/ ? '' : 'not '),
++$test;
print(("$x$x" !~ /^$x(??{$y})\z/ ? '' : 'not '),
++$test;
print(("$y$y" =~ /^$y(??{$y})\z/ ? '' : 'not '),
++$test;
print(("$x$y" =~ /^$x(??{$y})\z/ ? '' : 'not '),
++$test;
$y = $z; # reset $y after upgrade
print(("$x$y" !~ /^$x(??{$x})\z/ ? '' : 'not '),
++$test;
$y = $z; # reset $y after upgrade
print(("$y$y" !~ /^$y(??{$x})\z/ ? '' : 'not '),
++$test;
} # no re 'eval'
print "# more user-defined character properties\n";
sub IsSyriac1 {
return <<'END';
0712 072C
0730 074A
}
sub Syriac1 {
return <<'END';
0712 072C
0730 074A
}
{
print "# Change #18179\n";
# previously failed with "panic: end_shift
my $s = "\x{100}" x 5;
++$test;
}
{
print "# [perl #15763]\n";
$a = "x\x{100}";
chop $a; # but leaves the UTF-8 flag
$a .= "y"; # 1 byte before "y"
$a = "\x{100}y"; # 2 bytes before "y"
$a = "\x{1000}y"; # 3 bytes before "y"
}
$_ = 'aaaaaaaaaa';
$x = "CD";
$x = "CD";
{
# [perl #18232]
"\x{100}" =~ /(.)/;
{ 'a' =~ /./; }
}
{
use utf8;
my $NormalChar = qr/[\p{IsDigit}\p{IsLower}\p{IsUpper}]/;
my $NormalWord = qr/${NormalChar}+?/;
$attr =~ /^$/;
}
{
use utf8;
"a" =~ m/[b]/;
}
{
$p = 1;
foreach (1,2,3,4) {
$p++ if /(??{ $p })/
}
tie $p, P;
foreach (1,2,3,4) {
/(??{ $p })/
}
}
{
# Subject: Odd regexp behavior
# From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
# Date: Wed, 26 Feb 2003 16:53:12 +0000
# Message-Id: <E18o4nw-0008Ly-00@wisbech.cl.cam.ac.uk>
# To: perl-unicode@perl.org
}
{
my $i;
"[perl #21411] (??{ .. }) corrupts split's stack");
"[perl #21411] (?{ .. }) version of the above");
}
{
}
{
}
{
}
{
"[perl #17757] Parse::RecDescent triggers infinite loop");
}
{
}
# bug #19049
$_="abcdef\n";
@x = m/./g;
ok(" \x{101}" =~ qr/\x{100}/i,
"<20030808193656.5109.1@llama.ni-s.u-net.com>");
ok(" \x{1E01}" =~ qr/\x{1E00}/i,
"<20030808193656.5109.1@llama.ni-s.u-net.com>");
ok(" \x{10428}" =~ qr/\x{10400}/i,
"<20030808193656.5109.1@llama.ni-s.u-net.com>");
ok(" \x{1E01}x" =~ qr/\x{1E00}X/i,
"<20030808193656.5109.1@llama.ni-s.u-net.com>");
{
# [perl #23769] Unicode regex broken on simple example
}
for (120 .. 130) {
ok(
'\x{...} misparsed in regexp near 127 char EXACT limit'
);
}
}
{
use warnings;
my @w;
}
"$x-$y";
}, 'captures can move backwards in string');
# last test 1056