diff options
author | SADAHIRO Tomoyuki <BQW10602@nifty.com> | 2006-12-27 08:11:38 +0900 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-12-26 14:22:15 +0000 |
commit | 1b0dc72f61d9780edd32851239bf805186676bb4 (patch) | |
tree | e1c0b95fa3ac9d5bef34b65695e865568b4ba765 | |
parent | 11bf5ae46dc4ca1e784f868ece0ae607048cd9a7 (diff) | |
download | perl-1b0dc72f61d9780edd32851239bf805186676bb4.tar.gz |
Re: Named-capture regex syntax
Message-Id: <20061226231027.8320.BQW10602@nifty.com>
p4raw-id: //depot/perl@29623
-rwxr-xr-x | t/op/pat.t | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/t/op/pat.t b/t/op/pat.t index f42847f8f6..84dc2e85f7 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -3665,27 +3665,28 @@ SKIP:{ } { - if (ord("A") == 193) { - for (1..10) { - print "ok $test # Skip: in EBCDIC"; - $test++; - } - } else { - use utf8; - # ñ = U+00F1 (n-tilde) - # ̧ = U+0327 (cedilla) - # ² = U+00B2 (superscript two) - - ok("..foo foo.." =~ /(?'ñ'foo) \k<ñ>/, 'Named capture UTF'); - ok($+{ñ} eq 'foo', 'Named capture UTF'); - ok("..bar bar.." =~ /(?<_ñ>bar) \k'_ñ'/, 'Named capture UTF'); - ok($+{_ñ} eq 'bar', 'Named capture UTF'); - ok("..abc abc.." =~ /(?'ç'abc) \k'ç'/, 'Named capture UTF'); - ok($+{ç} eq 'abc', 'Named capture UTF'); - ok("..xyz xyz.." =~ /(?'ņ̃'xyz) \k'ņ̃'/, 'Named capture UTF'); - ok($+{ņ̃} eq 'xyz', 'Named capture UTF'); - ok("..456 456.." =~ /(?<a²>456) \k'a²'/, 'Named capture UTF'); - ok($+{a²} eq '456', 'Named capture UTF'); + my @ary = ( + pack('U', 0x00F1), # n-tilde + '_'.pack('U', 0x00F1), # _ + n-tilde + 'c'.pack('U', 0x0327), # c + cedilla + pack('U*', 0x00F1, 0x0327), # n-tilde + cedilla + 'a'.pack('U', 0x00B2), # a + superscript two + pack('U', 0x0391), # ALPHA + pack('U', 0x0391).'2', # ALPHA + 2 + pack('U', 0x0391).'_', # ALPHA + _ + ); + for my $uni (@ary) { + my ($r1, $c1, $r2, $c2) = eval qq{ + use utf8; + scalar("..foo foo.." =~ /(?'${uni}'foo) \\k'${uni}'/), + \$+{${uni}}, + scalar("..bar bar.." =~ /(?<${uni}>bar) \\k<${uni}>/), + \$+{${uni}}; + }; + ok($r1, "Named capture UTF (?'')"); + ok(defined $c1 && $c1 eq 'foo', "Named capture UTF \%+"); + ok($r2, "Named capture UTF (?<>)"); + ok(defined $c2 && $c2 eq 'bar', "Named capture UTF \%+"); } } @@ -4239,7 +4240,7 @@ ok($@=~/\QSequence \k... not terminated in regex;\E/); iseq(0+$::test,$::TestCount,"Got the right number of tests!"); # Don't forget to update this! BEGIN { - $::TestCount = 1584; + $::TestCount = 1606; print "1..$::TestCount\n"; } |