use strict;
use warnings;
use 5.010;
-
+use Config;
sub run_tests;
BEGIN {
chdir 't' if -d 't';
@INC = ('../lib','.');
- do "re/ReTest.pl" or die $@;
+ require './test.pl';
+ skip_all_if_miniperl("miniperl can't load Tie::Hash::NamedCapture, need for %+ and %-");
}
-plan tests => 2510; # Update this when adding/deleting tests.
+plan tests => 2530; # Update this when adding/deleting tests.
run_tests() unless caller;
#
sub run_tests {
+ like("A \x{263a} B z C", qr/A . B (??{ "z" }) C/,
+ "Match UTF-8 char in presence of (??{ }); Bug 20000731.001");
{
- local $BugId = '20000731.001';
- ok "A \x{263a} B z C" =~ /A . B (??{ "z" }) C/,
- "Match UTF-8 char in presense of (??{ })";
- }
-
-
- {
- local $BugId = '20001021.005';
no warnings 'uninitialized';
- ok undef =~ /^([^\/]*)(.*)$/, "Used to cause a SEGV";
+ ok(undef =~ /^([^\/]*)(.*)$/, "Used to cause a SEGV; Bug 20001021.005");
}
{
- local $Message = 'bug id 20001008.001';
+ my $message = 'bug id 20001008.001';
my @x = ("stra\337e 138", "stra\337e 138");
for (@x) {
- ok s/(\d+)\s*([\w\-]+)/$1 . uc $2/e;
- ok my ($latin) = /^(.+)(?:\s+\d)/;
- iseq $latin, "stra\337e";
- ok $latin =~ s/stra\337e/straße/;
+ ok(s/(\d+)\s*([\w\-]+)/$1 . uc $2/e, $message);
+ ok(my ($latin) = /^(.+)(?:\s+\d)/, $message);
+ is($latin, "stra\337e", $message);
+ ok($latin =~ s/stra\337e/straße/, $message);
#
# Previous code follows, but outcommented - there were no tests.
#
}
}
-
{
- local $BugId = '20001028.003';
-
# Fist half of the bug.
- local $Message = 'HEBREW ACCENT QADMA matched by .*';
+ my $message = 'HEBREW ACCENT QADMA matched by .*; Bug 20001028.003';
my $X = chr (1448);
- ok my ($Y) = $X =~ /(.*)/;
- iseq $Y, v1448;
- iseq length ($Y), 1;
+ ok(my ($Y) = $X =~ /(.*)/, $message);
+ is($Y, v1448, $message);
+ is(length $Y, 1, $message);
# Second half of the bug.
- $Message = 'HEBREW ACCENT QADMA in replacement';
+ $message = 'HEBREW ACCENT QADMA in replacement; Bug 20001028.003';
$X = '';
$X =~ s/^/chr(1488)/e;
- iseq length $X, 1;
- iseq ord ($X), 1488;
+ is(length $X, 1, $message);
+ is(ord $X, 1488, $message);
}
-
{
- local $BugId = '20001108.001';
- local $Message = 'Repeated s///';
+ my $message = 'Repeated s///; Bug 20001108.001';
my $X = "Szab\x{f3},Bal\x{e1}zs";
my $Y = $X;
$Y =~ s/(B)/$1/ for 0 .. 3;
- iseq $Y, $X;
- iseq $X, "Szab\x{f3},Bal\x{e1}zs";
+ is($Y, $X, $message);
+ is($X, "Szab\x{f3},Bal\x{e1}zs", $message);
}
-
{
- local $BugId = '20000517.001';
- local $Message = 's/// on UTF-8 string';
+ my $message = 's/// on UTF-8 string; Bug 20000517.001';
my $x = "\x{100}A";
$x =~ s/A/B/;
- iseq $x, "\x{100}B";
- iseq length $x, 2;
+ is($x, "\x{100}B", $message);
+ is(length $x, 2, $message);
}
-
{
- local $BugId = '20001230.002';
- local $Message = '\C and É';
- ok "École" =~ /^\C\C(.)/ && $1 eq 'c';
- ok "École" =~ /^\C\C(c)/;
+ my $message = '\C and É; Bug 20001230.002';
+ ok("École" =~ /^\C\C(.)/ && $1 eq 'c', $message);
+ like("École", qr/^\C\C(c)/, $message);
}
-
{
# The original bug report had 'no utf8' here but that was irrelevant.
- local $BugId = '20010306.008';
- local $Message = "Don't dump core";
+
+ my $message = "Don't dump core; Bug 20010306.008";
my $a = "a\x{1234}";
- ok $a =~ m/\w/; # used to core dump.
+ like($a, qr/\w/, $message); # used to core dump.
}
-
{
- local $BugId = '20010410.006';
- local $Message = '/g in scalar context';
+ my $message = '/g in scalar context; Bug 20010410.006';
for my $rx ('/(.*?)\{(.*?)\}/csg',
'/(.*?)\{(.*?)\}/cg',
'/(.*?)\{(.*?)\}/sg',
\$i ++;
}
--
- iseq $i, 2;
+ is($i, 2, $message);
}
}
{
- local $BugId = "20010619.003";
# Amazingly vertical tabulator is the same in ASCII and EBCDIC.
for ("\n", "\t", "\014", "\r") {
- ok !/[[:print:]]/, "'$_' not in [[:print:]]";
+ unlike($_, qr/[[:print:]]/, sprintf "\\%03o not in [[:print:]]; Bug 20010619.003", ord $_);
}
for (" ") {
- ok /[[:print:]]/, "'$_' in [[:print:]]";
+ like($_, qr/[[:print:]]/, "'$_' in [[:print:]]; Bug 20010619.003");
}
}
-
-
{
# [ID 20010814.004] pos() doesn't work when using =~m// in list context
- local $BugId = '20010814.004';
+
$_ = "ababacadaea";
my $a = join ":", /b./gc;
my $b = join ":", /a./gc;
my $c = pos;
- iseq "$a $b $c", 'ba:ba ad:ae 10', "pos() works with () = m//";
+ is("$a $b $c", 'ba:ba ad:ae 10', "pos() works with () = m//; Bug 20010814.004");
}
-
{
# [ID 20010407.006] matching utf8 return values from
# functions does not work
- local $BugId = '20010407.006';
- local $Message = 'UTF-8 return values from functions';
+
+ my $message = 'UTF-8 return values from functions; Bug 20010407.006';
package ID_20010407_006;
sub x {"a\x{1234}"}
my $x = x;
my $y;
- ::ok $x =~ /(..)/;
+ ::ok($x =~ /(..)/, $message);
$y = $1;
- ::ok length ($y) == 2 && $y eq $x;
- ::ok x =~ /(..)/;
+ ::ok(length ($y) == 2 && $y eq $x, $message);
+ ::ok(x =~ /(..)/, $message);
$y = $1;
- ::ok length ($y) == 2 && $y eq $x;
+ ::ok(length ($y) == 2 && $y eq $x, $message);
}
{
ok $x =~ /.*?\200/, "High bit fine";
}
-
{
- local $Message = 'UTF-8 hash keys and /$/';
+ my $message = 'UTF-8 hash keys and /$/';
# http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters
# /2002-01/msg01327.html
for (keys %u) {
my $m1 = /^\w*$/ ? 1 : 0;
my $m2 = $u {$_} =~ /^\w*$/ ? 1 : 0;
- iseq $m1, $m2;
+ is($m1, $m2, $message);
}
}
-
{
- local $BugId = "20020124.005";
- local $PatchId = "14795";
- local $Message = "s///eg";
+ my $message = "s///eg [change 13f46d054db22cf4]; Bug 20020124.005";
for my $char ("a", "\x{df}", "\x{100}") {
my $x = "$char b $char";
"c" =~ /c/;
"x";
}ge;
- iseq substr ($x, 0, 1), substr ($x, -1, 1);
+ is(substr ($x, 0, 1), substr ($x, -1, 1), $message);
}
}
-
{
- local $BugId = "20020412.005";
- local $Message = "Correct pmop flags checked when empty pattern";
+ my $message = "Correct pmop flags checked when empty pattern; Bug 20020412.005";
# Requires reuse of last successful pattern.
my $num = 123;
$num =~ /\d/;
for (0 .. 1) {
- my $match = ?? + 0;
- ok $match != $_, $Message,
- sprintf "'match one' %s on %s iteration" =>
- $match ? 'succeeded' : 'failed',
- $_ ? 'second' : 'first';
+ my $match = m?? + 0;
+ ok($match != $_, $message)
+ or diag(sprintf "'match one' %s on %s iteration" =>
+ $match ? 'succeeded' : 'failed',
+ $_ ? 'second' : 'first');
}
$num =~ /(\d)/;
my $result = join "" => $num =~ //g;
- iseq $result, $num;
+ is($result, $num, $message);
}
-
{
- local $BugId = '20020630.002';
- local $Message = 'UTF-8 regex matches above 32k';
+ my $message = 'UTF-8 regex matches above 32k; Bug 20020630.002';
for (['byte', "\x{ff}"], ['utf8', "\x{1ff}"]) {
my ($type, $char) = @$_;
for my $len (32000, 32768, 33000) {
my $s = $char . "f" x $len;
my $r = $s =~ /$char([f]*)/gc;
- ok $r, $Message, "<$type x $len>";
- ok !$r || pos ($s) == $len + 1, $Message,
- "<$type x $len>; pos = @{[pos $s]}";
+ ok($r, $message) or diag("<$type x $len>");
+ ok(!$r || pos ($s) == $len + 1, $message)
+ or diag("<$type x $len>; pos = @{[pos $s]}");
}
}
}
{
- local $PatchId = '18179';
my $s = "\x{100}" x 5;
my $ok = $s =~ /(\x{100}{4})/;
my ($ord, $len) = (ord $1, length $1);
- ok $ok && $ord == 0x100 && $len == 4, "No panic: end_shift";
+ ok $ok && $ord == 0x100 && $len == 4, "No panic: end_shift [change 0e933229fa758625]";
}
-
{
- local $BugId = '15763';
our $a = "x\x{100}";
chop $a; # Leaves the UTF-8 flag
$a .= "y"; # 1 byte before 'y'.
- ok $a =~ /^\C/, 'match one \C on 1-byte UTF-8';
- ok $a =~ /^\C{1}/, 'match \C{1}';
+ like($a, qr/^\C/, 'match one \C on 1-byte UTF-8; Bug 15763');
+ like($a, qr/^\C{1}/, 'match \C{1}; Bug 15763');
- ok $a =~ /^\Cy/, 'match \Cy';
- ok $a =~ /^\C{1}y/, 'match \C{1}y';
+ like($a, qr/^\Cy/, 'match \Cy; Bug 15763');
+ like($a, qr/^\C{1}y/, 'match \C{1}y; Bug 15763');
- ok $a !~ /^\C\Cy/, q {don't match two \Cy};
- ok $a !~ /^\C{2}y/, q {don't match \C{2}y};
+ unlike($a, qr/^\C\Cy/, q {don't match two \Cy; Bug 15763});
+ unlike($a, qr/^\C{2}y/, q {don't match \C{2}y; Bug 15763});
$a = "\x{100}y"; # 2 bytes before "y"
- ok $a =~ /^\C/, 'match one \C on 2-byte UTF-8';
- ok $a =~ /^\C{1}/, 'match \C{1}';
- ok $a =~ /^\C\C/, 'match two \C';
- ok $a =~ /^\C{2}/, 'match \C{2}';
+ like($a, qr/^\C/, 'match one \C on 2-byte UTF-8; Bug 15763');
+ like($a, qr/^\C{1}/, 'match \C{1}; Bug 15763');
+ like($a, qr/^\C\C/, 'match two \C; Bug 15763');
+ like($a, qr/^\C{2}/, 'match \C{2}; Bug 15763');
- ok $a =~ /^\C\C\C/, 'match three \C on 2-byte UTF-8 and a byte';
- ok $a =~ /^\C{3}/, 'match \C{3}';
+ like($a, qr/^\C\C\C/, 'match three \C on 2-byte UTF-8 and a byte; Bug 15763');
+ like($a, qr/^\C{3}/, 'match \C{3}; Bug 15763');
- ok $a =~ /^\C\Cy/, 'match two \C';
- ok $a =~ /^\C{2}y/, 'match \C{2}';
+ like($a, qr/^\C\Cy/, 'match two \C; Bug 15763');
+ like($a, qr/^\C{2}y/, 'match \C{2}; Bug 15763');
- ok $a !~ /^\C\C\Cy/, q {don't match three \Cy};
- ok $a !~ /^\C{2}\Cy/, q {don't match \C{2}\Cy};
- ok $a !~ /^\C{3}y/, q {don't match \C{3}y};
+ unlike($a, qr/^\C\C\Cy/, q {don't match three \Cy; Bug 15763});
+ unlike($a, qr/^\C{2}\Cy/, q {don't match \C{2}\Cy; Bug 15763});
+ unlike($a, qr/^\C{3}y/, q {don't match \C{3}y; Bug 15763});
$a = "\x{1000}y"; # 3 bytes before "y"
- ok $a =~ /^\C/, 'match one \C on three-byte UTF-8';
- ok $a =~ /^\C{1}/, 'match \C{1}';
- ok $a =~ /^\C\C/, 'match two \C';
- ok $a =~ /^\C{2}/, 'match \C{2}';
- ok $a =~ /^\C\C\C/, 'match three \C';
- ok $a =~ /^\C{3}/, 'match \C{3}';
+ like($a, qr/^\C/, 'match one \C on three-byte UTF-8; Bug 15763');
+ like($a, qr/^\C{1}/, 'match \C{1}; Bug 15763');
+ like($a, qr/^\C\C/, 'match two \C; Bug 15763');
+ like($a, qr/^\C{2}/, 'match \C{2}; Bug 15763');
+ like($a, qr/^\C\C\C/, 'match three \C; Bug 15763');
+ like($a, qr/^\C{3}/, 'match \C{3}; Bug 15763');
- ok $a =~ /^\C\C\C\C/, 'match four \C on three-byte UTF-8 and a byte';
- ok $a =~ /^\C{4}/, 'match \C{4}';
+ like($a, qr/^\C\C\C\C/, 'match four \C on three-byte UTF-8 and a byte; Bug 15763');
+ like($a, qr/^\C{4}/, 'match \C{4}; Bug 15763');
- ok $a =~ /^\C\C\Cy/, 'match three \Cy';
- ok $a =~ /^\C{3}y/, 'match \C{3}y';
+ like($a, qr/^\C\C\Cy/, 'match three \Cy; Bug 15763');
+ like($a, qr/^\C{3}y/, 'match \C{3}y; Bug 15763');
- ok $a !~ /^\C\C\C\Cy/, q {don't match four \Cy};
- ok $a !~ /^\C{4}y/, q {don't match \C{4}y};
+ unlike($a, qr/^\C\C\C\Cy/, q {don't match four \Cy; Bug 15763});
+ unlike($a, qr/^\C{4}y/, q {don't match \C{4}y; Bug 15763});
}
{
- local $BugId = '15397';
- local $Message = 'UTF-8 matching';
- ok "\x{100}" =~ /\x{100}/;
- ok "\x{100}" =~ /(\x{100})/;
- ok "\x{100}" =~ /(\x{100}){1}/;
- ok "\x{100}\x{100}" =~ /(\x{100}){2}/;
- ok "\x{100}\x{100}" =~ /(\x{100})(\x{100})/;
+ my $message = 'UTF-8 matching; Bug 15397';
+ like("\x{100}", qr/\x{100}/, $message);
+ like("\x{100}", qr/(\x{100})/, $message);
+ like("\x{100}", qr/(\x{100}){1}/, $message);
+ like("\x{100}\x{100}", qr/(\x{100}){2}/, $message);
+ like("\x{100}\x{100}", qr/(\x{100})(\x{100})/, $message);
}
-
{
- local $BugId = '7471';
- local $Message = 'Neither ()* nor ()*? sets $1 when matched 0 times';
+ my $message = 'Neither ()* nor ()*? sets $1 when matched 0 times; Bug 7471';
local $_ = 'CD';
- ok /(AB)*?CD/ && !defined $1;
- ok /(AB)*CD/ && !defined $1;
+ ok(/(AB)*?CD/ && !defined $1, $message);
+ ok(/(AB)*CD/ && !defined $1, $message);
}
-
{
- local $BugId = '3547';
- local $Message = "Caching shouldn't prevent match";
+ my $message = "Caching shouldn't prevent match; Bug 3547";
my $pattern = "^(b+?|a){1,2}c";
- ok "bac" =~ /$pattern/ && $1 eq 'a';
- ok "bbac" =~ /$pattern/ && $1 eq 'a';
- ok "bbbac" =~ /$pattern/ && $1 eq 'a';
- ok "bbbbac" =~ /$pattern/ && $1 eq 'a';
+ ok("bac" =~ /$pattern/ && $1 eq 'a', $message);
+ ok("bbac" =~ /$pattern/ && $1 eq 'a', $message);
+ ok("bbbac" =~ /$pattern/ && $1 eq 'a', $message);
+ ok("bbbbac" =~ /$pattern/ && $1 eq 'a', $message);
}
-
-
{
- local $BugId = '18232';
- local $Message = '$1 should keep UTF-8 ness';
- ok "\x{100}" =~ /(.)/;
- iseq $1, "\x{100}", '$1 is UTF-8';
+ ok("\x{100}" =~ /(.)/, '$1 should keep UTF-8 ness; Bug 18232');
+ is($1, "\x{100}", '$1 is UTF-8; Bug 18232');
{ 'a' =~ /./; }
- iseq $1, "\x{100}", '$1 is still UTF-8';
- isneq $1, "\xC4\x80", '$1 is not non-UTF-8';
+ is($1, "\x{100}", '$1 is still UTF-8; Bug 18232');
+ isnt($1, "\xC4\x80", '$1 is not non-UTF-8; Bug 18232');
}
-
{
- local $BugId = '19767';
- local $Message = "Optimizer doesn't prematurely reject match";
+ my $message = "Optimizer doesn't prematurely reject match; Bug 19767";
use utf8;
my $attr = 'Name-1';
my $PredNameHyphen = qr /^${NormalWord}(\-${NormalWord})*?$/;
$attr =~ /^$/;
- ok $attr =~ $PredNameHyphen; # Original test.
+ like($attr, $PredNameHyphen, $message); # Original test.
"a" =~ m/[b]/;
- ok "0" =~ /\p{N}+\z/; # Variant.
+ like("0", qr/\p{N}+\z/, $message); # Variant.
}
-
{
- local $BugId = '20683';
- local $Message = "(??{ }) doesn't return stale values";
+ my $message = "(??{ }) doesn't return stale values; Bug 20683";
our $p = 1;
foreach (1, 2, 3, 4) {
$p ++ if /(??{ $p })/
}
- iseq $p, 5;
+ is($p, 5, $message);
{
package P;
foreach (1, 2, 3, 4) {
/(??{ $p })/
}
- iseq $p, 5;
+ is($p, 5, $message);
}
-
{
# Subject: Odd regexp behavior
# From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
# Message-Id: <E18o4nw-0008Ly-00@wisbech.cl.cam.ac.uk>
# To: perl-unicode@perl.org
- local $Message = 'Markus Kuhn 2003-02-26';
+ my $message = 'Markus Kuhn 2003-02-26';
my $x = "\x{2019}\nk";
- ok $x =~ s/(\S)\n(\S)/$1 $2/sg;
- ok $x eq "\x{2019} k";
+ ok($x =~ s/(\S)\n(\S)/$1 $2/sg, $message);
+ is($x, "\x{2019} k", $message);
$x = "b\nk";
- ok $x =~ s/(\S)\n(\S)/$1 $2/sg;
- ok $x eq "b k";
+ ok($x =~ s/(\S)\n(\S)/$1 $2/sg, $message);
+ is($x, "b k", $message);
- ok "\x{2019}" =~ /\S/;
+ like("\x{2019}", qr/\S/, $message);
}
-
{
- local $BugId = '21411';
- local $Message = "(??{ .. }) in split doesn't corrupt its stack";
+ my $message = "(??{ .. }) in split doesn't corrupt its stack; Bug 21411";
our $i;
- ok '-1-3-5-' eq join '', split /((??{$i++}))/, '-1-3-5-';
+ is('-1-3-5-', join('', split /((??{$i++}))/, '-1-3-5-'), $message);
no warnings 'syntax';
@_ = split /(?{'WOW'})/, 'abc';
local $" = "|";
- iseq "@_", "a|b|c";
- }
-
-
- {
- # XXX DAPM 13-Apr-06. Recursive split is still broken. It's only luck it
- # hasn't been crashing. Disable this test until it is fixed properly.
- # XXX also check what it returns rather than just doing ok(1,...)
- # split /(?{ split "" })/, "abc";
- local $TODO = "Recursive split is still broken";
- ok 0, 'cache_re & "(?{": it dumps core in 5.6.1 & 5.8.0';
+ is("@_", "a|b|c", $message);
}
+ is(join('-', split /(?{ split "" })/, "abc"), 'a-b-c', 'nested split');
{
- local $BugId = '17757';
$_ = "code: 'x' { '...' }\n"; study;
my @x; push @x, $& while m/'[^\']*'/gx;
local $" = ":";
- iseq "@x", "'x':'...'", "Parse::RecDescent triggered infinite loop";
+ is("@x", "'x':'...'", "Parse::RecDescent triggered infinite loop; Bug 17757");
}
-
{
- local $BugId = '22354';
sub func ($) {
- ok "a\nb" !~ /^b/, "Propagated modifier; $_[0]";
- ok "a\nb" =~ /^b/m, "Propagated modifier; $_[0] - with /m";
+ ok("a\nb" !~ /^b/, "Propagated modifier; $_[0]; Bug 22354");
+ ok("a\nb" =~ /^b/m, "Propagated modifier; $_[0] - with /m; Bug 22354");
}
func "standalone";
$_ = "x"; s/x/func "in subst"/e;
$_ = "x"; s/x/func "in multiline subst"/em;
-
- #
- # Next two give 'panic: malloc'.
- # Outcommented, using two TODOs.
- #
- local $TODO = 'panic: malloc';
- local $Message = 'Postponed regexp and propaged modifier';
- # ok 0 for 1 .. 2;
- SKIP: {
- skip "panic: malloc", 2;
- $_ = "x"; /x(?{func "in regexp"})/;
- $_ = "x"; /x(?{func "in multiline regexp"})/m;
- }
+ $_ = "x"; /x(?{func "in regexp"})/;
+ $_ = "x"; /x(?{func "in multiline regexp"})/m;
}
-
{
- local $BugId = '19049';
$_ = "abcdef\n";
my @x = m/./g;
- iseq "abcde", $`, 'Global match sets $`';
+ is("abcde", $`, 'Global match sets $`; Bug 19049');
}
-
{
# [perl #23769] Unicode regex broken on simple example
# regrepeat() didn't handle UTF-8 EXACT case right.
- local $BugId = '23769';
+
my $Mess = 'regrepeat() handles UTF-8 EXACT case right';
- local $Message = $Mess;
+ my $message = "$Mess; Bug 23769";
my $s = "\x{a0}\x{a0}\x{a0}\x{100}"; chop $s;
- ok $s =~ /\x{a0}/;
- ok $s =~ /\x{a0}+/;
- ok $s =~ /\x{a0}\x{a0}/;
+ like($s, qr/\x{a0}/, $message);
+ like($s, qr/\x{a0}+/, $message);
+ like($s, qr/\x{a0}\x{a0}/, $message);
- $Message = "$Mess (easy variant)";
- ok "aaa\x{100}" =~ /(a+)/;
- iseq $1, "aaa";
+ $message = "$Mess (easy variant); Bug 23769";
+ ok("aaa\x{100}" =~ /(a+)/, $message);
+ is($1, "aaa", $message);
- $Message = "$Mess (easy invariant)";
- ok "aaa\x{100} " =~ /(a+?)/;
- iseq $1, "a";
+ $message = "$Mess (easy invariant); Bug 23769";
+ ok("aaa\x{100} " =~ /(a+?)/, $message);
+ is($1, "a", $message);
- $Message = "$Mess (regrepeat variant)";
- ok "\xa0\xa0\xa0\x{100} " =~ /(\xa0+?)/;
- iseq $1, "\xa0";
+ $message = "$Mess (regrepeat variant); Bug 23769";
+ ok("\xa0\xa0\xa0\x{100} " =~ /(\xa0+?)/, $message);
+ is($1, "\xa0", $message);
- $Message = "$Mess (regrepeat invariant)";
- ok "\xa0\xa0\xa0\x{100}" =~ /(\xa0+)/;
- iseq $1, "\xa0\xa0\xa0";
+ $message = "$Mess (regrepeat invariant); Bug 23769";
+ ok("\xa0\xa0\xa0\x{100}" =~ /(\xa0+)/, $message);
+ is($1, "\xa0\xa0\xa0", $message);
- $Message = "$Mess (hard variant)";
- ok "\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+?)/;
- iseq $1, "\xa0\xa1";
+ $message = "$Mess (hard variant); Bug 23769";
+ ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+?)/, $message);
+ is($1, "\xa0\xa1", $message);
- $Message = "$Mess (hard invariant)";
- ok "ababab\x{100} " =~ /((?:ab)+)/;
- iseq $1, 'ababab';
+ $message = "$Mess (hard invariant); Bug 23769";
+ ok("ababab\x{100} " =~ /((?:ab)+)/, $message);
+ is($1, 'ababab', $message);
- ok "\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+)/;
- iseq $1, "\xa0\xa1\xa0\xa1\xa0\xa1";
+ ok("\xa0\xa1\xa0\xa1\xa0\xa1\x{100}" =~ /((?:\xa0\xa1)+)/, $message);
+ is($1, "\xa0\xa1\xa0\xa1\xa0\xa1", $message);
- ok "ababab\x{100} " =~ /((?:ab)+?)/;
- iseq $1, "ab";
+ ok("ababab\x{100} " =~ /((?:ab)+?)/, $message);
+ is($1, "ab", $message);
- $Message = "Don't match first byte of UTF-8 representation";
- ok "\xc4\xc4\xc4" !~ /(\x{100}+)/;
- ok "\xc4\xc4\xc4" !~ /(\x{100}+?)/;
- ok "\xc4\xc4\xc4" !~ /(\x{100}++)/;
+ $message = "Don't match first byte of UTF-8 representation; Bug 23769";
+ unlike("\xc4\xc4\xc4", qr/(\x{100}+)/, $message);
+ unlike("\xc4\xc4\xc4", qr/(\x{100}+?)/, $message);
+ unlike("\xc4\xc4\xc4", qr/(\x{100}++)/, $message);
}
-
{
# perl panic: pp_match start/end pointers
- local $BugId = '25269';
- iseq "a-bc", eval {my ($x, $y) = "bca" =~ /^(?=.*(a)).*(bc)/; "$x-$y"},
- 'Captures can move backwards in string';
- }
+ is(eval {my ($x, $y) = "bca" =~ /^(?=.*(a)).*(bc)/; "$x-$y"}, "a-bc",
+ 'Captures can move backwards in string; Bug 25269');
+ }
{
- local $BugId = '27940'; # \cA not recognized in character classes
- ok "a\cAb" =~ /\cA/, '\cA in pattern';
- ok "a\cAb" =~ /[\cA]/, '\cA in character class';
- ok "a\cAb" =~ /[\cA-\cB]/, '\cA in character class range';
- ok "abc" =~ /[^\cA-\cB]/, '\cA in negated character class range';
- ok "a\cBb" =~ /[\cA-\cC]/, '\cB in character class range';
- ok "a\cCbc" =~ /[^\cA-\cB]/, '\cC in negated character class range';
- ok "a\cAb" =~ /(??{"\cA"})/, '\cA in ??{} pattern';
- ok "ab" !~ /a\cIb/x, '\cI in pattern';
+ # \cA not recognized in character classes
+ like("a\cAb", qr/\cA/, '\cA in pattern; Bug 27940');
+ like("a\cAb", qr/[\cA]/, '\cA in character class; Bug 27940');
+ like("a\cAb", qr/[\cA-\cB]/, '\cA in character class range; Bug 27940');
+ like("abc", qr/[^\cA-\cB]/, '\cA in negated character class range; Bug 27940');
+ like("a\cBb", qr/[\cA-\cC]/, '\cB in character class range; Bug 27940');
+ like("a\cCbc", qr/[^\cA-\cB]/, '\cC in negated character class range; Bug 27940');
+ like("a\cAb", qr/(??{"\cA"})/, '\cA in ??{} pattern; Bug 27940');
+ unlike("ab", qr/a\cIb/x, '\cI in pattern; Bug 27940');
}
-
{
# perl #28532: optional zero-width match at end of string is ignored
- local $BugId = '28532';
- ok "abc" =~ /^abc(\z)?/ && defined($1),
- 'Optional zero-width match at end of string';
- ok "abc" =~ /^abc(\z)??/ && !defined($1),
- 'Optional zero-width match at end of string';
- }
-
+ ok("abc" =~ /^abc(\z)?/ && defined($1),
+ 'Optional zero-width match at end of string; Bug 28532');
+ ok("abc" =~ /^abc(\z)??/ && !defined($1),
+ 'Optional zero-width match at end of string; Bug 28532');
+ }
{
- local $BugId = '36207';
my $utf8 = "\xe9\x{100}"; chop $utf8;
my $latin1 = "\xe9";
- ok $utf8 =~ /\xe9/i, "utf8/latin";
- ok $utf8 =~ /$latin1/i, "utf8/latin runtime";
- ok $utf8 =~ /(abc|\xe9)/i, "utf8/latin trie";
- ok $utf8 =~ /(abc|$latin1)/i, "utf8/latin trie runtime";
+ like($utf8, qr/\xe9/i, "utf8/latin; Bug 36207");
+ like($utf8, qr/$latin1/i, "utf8/latin runtime; Bug 36207");
+ like($utf8, qr/(abc|\xe9)/i, "utf8/latin trie; Bug 36207");
+ like($utf8, qr/(abc|$latin1)/i, "utf8/latin trie runtime; Bug 36207");
- ok "\xe9" =~ /$utf8/i, "latin/utf8";
- ok "\xe9" =~ /(abc|$utf8)/i, "latin/utf8 trie";
- ok $latin1 =~ /$utf8/i, "latin/utf8 runtime";
- ok $latin1 =~ /(abc|$utf8)/i, "latin/utf8 trie runtime";
+ like("\xe9", qr/$utf8/i, "latin/utf8; Bug 36207");
+ like("\xe9", qr/(abc|$utf8)/i, "latin/utf8 trie; Bug 36207");
+ like($latin1, qr/$utf8/i, "latin/utf8 runtime; Bug 36207");
+ like($latin1, qr/(abc|$utf8)/i, "latin/utf8 trie runtime; Bug 36207");
}
-
{
- local $BugId = '37038';
my $s = "abcd";
$s =~ /(..)(..)/g;
$s = $1;
$s = $2;
- iseq $2, 'cd',
- "Assigning to original string does not corrupt match vars";
+ is($2, 'cd',
+ "Assigning to original string does not corrupt match vars; Bug 37038");
}
-
{
- local $PatchId = '26410';
{
package wooosh;
sub gloople {"!"}
}
my $aeek = bless {} => 'wooosh';
- eval_ok sub {$aeek -> gloople () =~ /(.)/g},
- "//g match against return value of sub";
+ is(do {$aeek -> gloople () =~ /(.)/g}, 1,
+ "//g match against return value of sub [change e26a497577f3ce7b]");
sub gloople {"!"}
- eval_ok sub {gloople () =~ /(.)/g},
- "26410 didn't affect sub calls for some reason";
+ is(do{gloople () =~ /(.)/g}, 1,
+ "change e26a497577f3ce7b didn't affect sub calls for some reason");
}
-
{
- local $TODO = "See changes 26925-26928, which reverted change 26410";
+ # [perl #78680]
+ # See changes 26925-26928, which reverted change 26410
{
package lv;
our $var = "abc";
1;
};
if ($r) {
- iseq $f, "ab", "pos() retained between calls";
+ is($f, "ab", "pos() retained between calls");
}
else {
- local $TODO;
ok 0, "Code failed: $@";
}
1;
};
if ($s) {
- iseq $g, "ab", "pos() retained between calls";
+ is($g, "ab", "pos() retained between calls");
}
else {
- local $TODO;
ok 0, "Code failed: $@";
}
}
-
SKIP:
{
- local $BugId = '37836';
- skip "In EBCDIC" if $IS_EBCDIC;
+ skip "In EBCDIC" if $::IS_EBCDIC;
no warnings 'utf8';
$_ = pack 'U0C2', 0xa2, 0xf8; # Ill-formed UTF-8
my $ret = 0;
- eval_ok sub {!($ret = s/[\0]+//g)},
- "Ill-formed UTF-8 doesn't match NUL in class";
+ is(do {!($ret = s/[\0]+//g)}, 1,
+ "Ill-formed UTF-8 doesn't match NUL in class; Bug 37836");
}
-
{
# chr(65535) should be allowed in regexes
- local $BugId = '38293';
+
no warnings 'utf8'; # To allow non-characters
my ($c, $r, $s);
$c = chr 0xffff;
$c =~ s/$c//g;
- ok $c eq "", "U+FFFF, parsed as atom";
+ is($c, "", "U+FFFF, parsed as atom; Bug 38293");
$c = chr 0xffff;
$r = "\\$c";
$c =~ s/$r//g;
- ok $c eq "", "U+FFFF backslashed, parsed as atom";
+ is($c, "", "U+FFFF backslashed, parsed as atom; Bug 38293");
$c = chr 0xffff;
$c =~ s/[$c]//g;
- ok $c eq "", "U+FFFF, parsed in class";
+ is($c, "", "U+FFFF, parsed in class; Bug 38293");
$c = chr 0xffff;
$r = "[\\$c]";
$c =~ s/$r//g;
- ok $c eq "", "U+FFFF backslashed, parsed in class";
+ is($c, "", "U+FFFF backslashed, parsed in class; Bug 38293");
$s = "A\x{ffff}B";
$s =~ s/\x{ffff}//i;
- ok $s eq "AB", "U+FFFF, EXACTF";
+ is($s, "AB", "U+FFFF, EXACTF; Bug 38293");
$s = "\x{ffff}A";
$s =~ s/\bA//;
- ok $s eq "\x{ffff}", "U+FFFF, BOUND";
+ is($s, "\x{ffff}", "U+FFFF, BOUND; Bug 38293");
$s = "\x{ffff}!";
$s =~ s/\B!//;
- ok $s eq "\x{ffff}", "U+FFFF, NBOUND";
+ is($s, "\x{ffff}", "U+FFFF, NBOUND; Bug 38293");
}
-
{
- local $BugId = '39583';
# The printing characters
my @chars = ("A" .. "Z");
$str .= ($delim x 4);
my $res;
my $matched;
- ok $str =~ s/^(.*?)${delim}{4}//s, "Pattern matches";
- iseq $str, "", "Empty string";
- ok defined $1 && length ($1) == $size, '$1 is correct size';
+ ok($str =~ s/^(.*?)${delim}{4}//s, "Pattern matches; Bug 39583");
+ is($str, "", "Empty string; Bug 39583");
+ ok(defined $1 && length ($1) == $size, '$1 is correct size; Bug 39583');
}
-
{
- local $BugId = '27940';
- ok "\0-A" =~ /\c@-A/, '@- should not be interpolated in a pattern';
- ok "\0\0A" =~ /\c@+A/, '@+ should not be interpolated in a pattern';
- ok "X\@-A" =~ /X@-A/, '@- should not be interpolated in a pattern';
- ok "X\@\@A" =~ /X@+A/, '@+ should not be interpolated in a pattern';
+ like("\0-A", qr/\c@-A/, '@- should not be interpolated in a pattern; Bug 27940');
+ like("\0\0A", qr/\c@+A/, '@+ should not be interpolated in a pattern; Bug 27940');
+ like("X\@-A", qr/X@-A/, '@- should not be interpolated in a pattern; Bug 27940');
+ like("X\@\@A", qr/X@+A/, '@+ should not be interpolated in a pattern; Bug 27940');
- ok "X\0A" =~ /X\c@?A/, '\c@?';
- ok "X\0A" =~ /X\c@*A/, '\c@*';
- ok "X\0A" =~ /X\c@(A)/, '\c@(';
- ok "X\0A" =~ /X(\c@)A/, '\c@)';
- ok "X\0A" =~ /X\c@|ZA/, '\c@|';
+ like("X\0A", qr/X\c@?A/, '\c@?; Bug 27940');
+ like("X\0A", qr/X\c@*A/, '\c@*; Bug 27940');
+ like("X\0A", qr/X\c@(A)/, '\c@(; Bug 27940');
+ like("X\0A", qr/X(\c@)A/, '\c@); Bug 27940');
+ like("X\0A", qr/X\c@|ZA/, '\c@|; Bug 27940');
- ok "X\@A" =~ /X@?A/, '@?';
- ok "X\@A" =~ /X@*A/, '@*';
- ok "X\@A" =~ /X@(A)/, '@(';
- ok "X\@A" =~ /X(@)A/, '@)';
- ok "X\@A" =~ /X@|ZA/, '@|';
+ like("X\@A", qr/X@?A/, '@?; Bug 27940');
+ like("X\@A", qr/X@*A/, '@*; Bug 27940');
+ like("X\@A", qr/X@(A)/, '@(; Bug 27940');
+ like("X\@A", qr/X(@)A/, '@); Bug 27940');
+ like("X\@A", qr/X@|ZA/, '@|; Bug 27940');
local $" = ','; # non-whitespace and non-RE-specific
- ok 'abc' =~ /(.)(.)(.)/, 'The last successful match is bogus';
- ok "A@+B" =~ /A@{+}B/, 'Interpolation of @+ in /@{+}/';
- ok "A@-B" =~ /A@{-}B/, 'Interpolation of @- in /@{-}/';
- ok "A@+B" =~ /A@{+}B/x, 'Interpolation of @+ in /@{+}/x';
- ok "A@-B" =~ /A@{-}B/x, 'Interpolation of @- in /@{-}/x';
+ like('abc', qr/(.)(.)(.)/, 'The last successful match is bogus; Bug 27940');
+ like("A@+B", qr/A@{+}B/, 'Interpolation of @+ in /@{+}/; Bug 27940');
+ like("A@-B", qr/A@{-}B/, 'Interpolation of @- in /@{-}/; Bug 27940');
+ like("A@+B", qr/A@{+}B/x, 'Interpolation of @+ in /@{+}/x; Bug 27940');
+ like("A@-B", qr/A@{-}B/x, 'Interpolation of @- in /@{-}/x; Bug 27940');
}
-
{
- local $BugId = '50496';
my $s = 'foo bar baz';
my (@k, @v, @fetch, $res);
my $count = 0;
}
foreach (0 .. 2) {
if ($fetch [$_]) {
- iseq $fetch [$_] [0], $fetch [$_] [1], $names [$_];
+ is($fetch[$_][0], $fetch[$_][1], "$names[$_]; Bug 50496");
} else {
ok 0, $names[$_];
}
}
- iseq $res, 1, "'$s' =~ /(?<A>foo)\\s+(?<B>bar)?\\s+(?<C>baz)/";
- iseq $count, 3, "Got 3 keys in %+ via each";
- iseq 0 + @k, 3, 'Got 3 keys in %+ via keys';
- iseq "@k", "A B C", "Got expected keys";
- iseq "@v", "bar baz foo", "Got expected values";
+ is($res, 1, "'$s' =~ /(?<A>foo)\\s+(?<B>bar)?\\s+(?<C>baz)/; Bug 50496");
+ is($count, 3, "Got 3 keys in %+ via each; Bug 50496");
+ is(0 + @k, 3, "Got 3 keys in %+ via keys; Bug 50496");
+ is("@k", "A B C", "Got expected keys; Bug 50496");
+ is("@v", "bar baz foo", "Got expected values; Bug 50496");
eval '
no warnings "uninitialized";
print for $+ {this_key_doesnt_exist};
';
- ok !$@, 'lvalue $+ {...} should not throw an exception';
+ is($@, '', 'lvalue $+ {...} should not throw an exception; Bug 50496');
}
-
{
#
# Almost the same as the block above, except that the capture is nested.
#
- local $BugId = '50496';
+
my $s = 'foo bar baz';
my (@k, @v, @fetch, $res);
my $count = 0;
}
foreach (0 .. 3) {
if ($fetch [$_]) {
- iseq $fetch [$_] [0], $fetch [$_] [1], $names [$_];
+ is($fetch[$_][0], $fetch[$_][1], "$names[$_]; Bug 50496");
} else {
ok 0, $names [$_];
}
}
- iseq $res, 1, "'$s' =~ /(?<D>(?<A>foo)\\s+(?<B>bar)?\\s+(?<C>baz))/";
- iseq $count, 4, "Got 4 keys in %+ via each";
- iseq @k, 4, 'Got 4 keys in %+ via keys';
- iseq "@k", "A B C D", "Got expected keys";
- iseq "@v", "bar baz foo foo bar baz", "Got expected values";
+ is($res, 1, "'$s' =~ /(?<D>(?<A>foo)\\s+(?<B>bar)?\\s+(?<C>baz))/; Bug 50496");
+ is($count, 4, "Got 4 keys in %+ via each; Bug 50496");
+ is(@k, 4, "Got 4 keys in %+ via keys; Bug 50496");
+ is("@k", "A B C D", "Got expected keys; Bug 50496");
+ is("@v", "bar baz foo foo bar baz", "Got expected values; Bug 50496");
eval '
no warnings "uninitialized";
print for $+ {this_key_doesnt_exist};
';
- ok !$@,'lvalue $+ {...} should not throw an exception';
+ is($@, '', 'lvalue $+ {...} should not throw an exception; Bug 50496');
}
-
{
- local $BugId = '36046';
my $str = 'abc';
my $count = 0;
my $mval = 0;
my $pval = 0;
while ($str =~ /b/g) {$mval = $#-; $pval = $#+; $count ++}
- iseq $mval, 0, '@- should be empty';
- iseq $pval, 0, '@+ should be empty';
- iseq $count, 1, 'Should have matched once only';
+ is($mval, 0, '@- should be empty; Bug 36046');
+ is($pval, 0, '@+ should be empty; Bug 36046');
+ is($count, 1, 'Should have matched once only; Bug 36046');
}
-
-
-
{
- local $BugId = '40684';
- local $Message = '/m in precompiled regexp';
+ my $message = '/m in precompiled regexp; Bug 40684';
my $s = "abc\ndef";
my $rex = qr'^abc$'m;
- ok $s =~ m/$rex/;
- ok $s =~ m/^abc$/m;
+ ok($s =~ m/$rex/, $message);
+ ok($s =~ m/^abc$/m, $message);
}
-
{
- local $BugId = '36909';
- local $Message = '(?: ... )? should not lose $^R';
+ my $message = '(?: ... )? should not lose $^R; Bug 36909';
$^R = 'Nothing';
{
local $^R = "Bad";
- ok 'x foofoo y' =~ m {
+ ok('x foofoo y' =~ m {
(foo) # $^R correctly set
(?{ "last regexp code result" })
- }x;
- iseq $^R, 'last regexp code result';
+ }x, $message);
+ is($^R, 'last regexp code result', $message);
}
- iseq $^R, 'Nothing';
+ is($^R, 'Nothing', $message);
{
local $^R = "Bad";
- ok 'x foofoo y' =~ m {
+ ok('x foofoo y' =~ m {
(?:foo|bar)+ # $^R correctly set
(?{ "last regexp code result" })
- }x;
- iseq $^R, 'last regexp code result';
+ }x, $message);
+ is($^R, 'last regexp code result', $message);
}
- iseq $^R, 'Nothing';
+ is($^R, 'Nothing', $message);
{
local $^R = "Bad";
- ok 'x foofoo y' =~ m {
+ ok('x foofoo y' =~ m {
(foo|bar)\1+ # $^R undefined
(?{ "last regexp code result" })
- }x;
- iseq $^R, 'last regexp code result';
+ }x, $message);
+ is($^R, 'last regexp code result', $message);
}
- iseq $^R, 'Nothing';
+ is($^R, 'Nothing', $message);
{
local $^R = "Bad";
- ok 'x foofoo y' =~ m {
+ ok('x foofoo y' =~ m {
(foo|bar)\1 # This time without the +
(?{"last regexp code result"})
- }x;
- iseq $^R, 'last regexp code result';
+ }x, $message);
+ is($^R, 'last regexp code result', $message);
}
- iseq $^R, 'Nothing';
+ is($^R, 'Nothing', $message);
}
-
{
- local $BugId = '22395';
- local $Message = 'Match is linear, not quadratic';
+ my $message = 'Match is linear, not quadratic; Bug 22395';
our $count;
for my $l (10, 100, 1000) {
$count = 0;
('a' x $l) =~ /(.*)(?{$count++})[bc]/;
- local $TODO = "Should be L+1 not L*(L+3)/2 (L=$l)";
- iseq $count, $l + 1;
+ local $::TODO = "Should be L+1 not L*(L+3)/2 (L=$l)";
+ is($count, $l + 1, $message);
}
}
-
{
- local $BugId = '22614';
- local $Message = '@-/@+ should not have undefined values';
+ my $message = '@-/@+ should not have undefined values; Bug 22614';
local $_ = 'ab';
our @len = ();
/(.){1,}(?{push @len,0+@-})(.){1,}(?{})^/;
- iseq "@len", "2 2 2";
+ is("@len", "2 2 2", $message);
}
-
{
- local $BugId = '18209';
- local $Message = '$& set on s///';
+ my $message = '$& set on s///; Bug 18209';
my $text = ' word1 word2 word3 word4 word5 word6 ';
my @words = ('word1', 'word3', 'word5');
my $count;
foreach my $word (@words) {
- $text =~ s/$word\s//gi; # Leave a space to seperate words
+ $text =~ s/$word\s//gi; # Leave a space to separate words
# in the resultant str.
# The following block is not working.
if ($&) {
}
# End bad block
}
- iseq $count, 3;
- iseq $text, ' word2 word4 word6 ';
+ is($count, 3, $message);
+ is($text, ' word2 word4 word6 ', $message);
}
-
{
# RT#6893
- local $BugId = '6893';
+
local $_ = qq (A\nB\nC\n);
my @res;
while (m#(\G|\n)([^\n]*)\n#gsx) {
push @res, "$2";
last if @res > 3;
}
- iseq "@res", "A B C", "/g pattern shouldn't infinite loop";
+ is("@res", "A B C", "/g pattern shouldn't infinite loop; Bug 6893");
}
-
-
{
- local $BugId = '41010';
- local $Message = 'No optimizer bug';
+ # No optimizer bug
my @tails = ('', '(?(1))', '(|)', '()?');
my @quants = ('*','+');
my $doit = sub {
for my $quant (@quants) {
for my $tail (@tails) {
my $re = "($pat$quant\$)$tail";
- ok /$re/ && $1 eq $_, "'$_' =~ /$re/";
- ok /$re/m && $1 eq $_, "'$_' =~ /$re/m";
+ ok(/$re/ && $1 eq $_, "'$_' =~ /$re/; Bug 41010");
+ ok(/$re/m && $1 eq $_, "'$_' =~ /$re/m; Bug 41010");
}
}
}
$doit -> (\@dpats, @dstrs);
}
-
-
{
- local $BugId = '45605';
# [perl #45605] Regexp failure with utf8-flagged and byte-flagged string
my $utf_8 = "\xd6schel";
utf8::upgrade ($utf_8);
$utf_8 =~ m {(\xd6|Ö)schel};
- iseq $1, "\xd6", "Upgrade error";
+ is($1, "\xd6", "Upgrade error; Bug 45605");
}
{
# Regardless of utf8ness any character matches itself when
# doing a case insensitive match. See also [perl #36207]
- local $BugId = '36207';
+
for my $o (0 .. 255) {
my @ch = (chr ($o), chr ($o));
utf8::upgrade ($ch [1]);
for my $u_str (0, 1) {
for my $u_pat (0, 1) {
- ok $ch [$u_str] =~ /\Q$ch[$u_pat]\E/i,
- "\$c =~ /\$c/i : chr ($o) : u_str = $u_str u_pat = $u_pat";
- ok $ch [$u_str] =~ /\Q$ch[$u_pat]\E|xyz/i,
- "\$c=~/\$c|xyz/i : chr($o) : u_str = $u_str u_pat = $u_pat";
+ like($ch[$u_str], qr/\Q$ch[$u_pat]\E/i,
+ "\$c =~ /\$c/i : chr ($o) : u_str = $u_str u_pat = $u_pat; Bug 36207");
+ like($ch[$u_str], qr/\Q$ch[$u_pat]\E|xyz/i,
+ "\$c=~/\$c|xyz/i : chr($o) : u_str = $u_str u_pat = $u_pat; Bug 36207");
}
}
}
}
-
{
- local $BugId = '49190';
- local $Message = '$REGMARK in replacement';
+ my $message = '$REGMARK in replacement; Bug 49190';
our $REGMARK;
my $_ = "A";
- ok s/(*:B)A/$REGMARK/;
- iseq $_, "B";
+ ok(s/(*:B)A/$REGMARK/, $message);
+ is($_, "B", $message);
$_ = "CCCCBAA";
- ok s/(*:X)A+|(*:Y)B+|(*:Z)C+/$REGMARK/g;
- iseq $_, "ZYX";
+ ok(s/(*:X)A+|(*:Y)B+|(*:Z)C+/$REGMARK/g, $message);
+ is($_, "ZYX", $message);
+ # Use a longer name to force reallocation of $REGMARK.
+ $_ = "CCCCBAA";
+ ok(s/(*:X)A+|(*:YYYYYYYYYYYYYYYY)B+|(*:Z)C+/$REGMARK/g, $message);
+ is($_, "ZYYYYYYYYYYYYYYYYX", $message);
}
-
{
- local $BugId = '52658';
- local $Message = 'Substitution evaluation in list context';
+ my $message = 'Substitution evaluation in list context; Bug 52658';
my $reg = '../xxx/';
my @te = ($reg =~ m{^(/?(?:\.\./)*)},
$reg =~ s/(x)/'b'/eg > 1 ? '##' : '++');
- iseq $reg, '../bbb/';
- iseq $te [0], '../';
+ is($reg, '../bbb/', $message);
+ is($te [0], '../', $message);
}
- # This currently has to come before any "use encoding" in this file.
{
- local $Message;
- local $BugId = '59342';
- must_warn 'qr/\400/', '^Use of octal value above 377';
- }
-
-
-
- {
- local $BugId = '60034';
my $a = "xyzt" x 8192;
- ok $a =~ /\A(?>[a-z])*\z/,
- '(?>) does not cause wrongness on long string';
+ like($a, qr/\A(?>[a-z])*\z/,
+ '(?>) does not cause wrongness on long string; Bug 60034');
my $b = $a . chr 256;
chop $b;
- {
- iseq $a, $b;
- }
- ok $b =~ /\A(?>[a-z])*\z/,
- '(?>) does not cause wrongness on long string with UTF-8';
+ is($a, $b, 'Bug 60034');
+ like($b, qr/\A(?>[a-z])*\z/,
+ '(?>) does not cause wrongness on long string with UTF-8; Bug 60034');
}
-
#
# Keep the following tests last -- they may crash perl
#
print "# Tests that follow may crash perl\n";
{
- local $BugId = '19049/38869';
- local $Message = 'Pattern in a loop, failure should not ' .
- 'affect previous success';
+
+ my $message = 'Pattern in a loop, failure should not ' .
+ 'affect previous success; Bug 19049/38869';
my @list = (
'ab cdef', # Matches regex
('e' x 40000 ) .'ab c' # Matches not, but 'ab c' matches part of it
$y = $1; # Use $1, which might not be from the last match!
$x = substr ($list [0], $- [0], $+ [0] - $- [0]);
}
- iseq $y, ' ';
- iseq $x, 'ab cd';
+ is($y, ' ', $message);
+ is($x, 'ab cd', $message);
}
-
{
- local $BugId = '24274';
-
- ok (("a" x (2 ** 15 - 10)) =~ /^()(a|bb)*$/, "Recursive stack cracker");
+ ok (("a" x (2 ** 15 - 10)) =~ /^()(a|bb)*$/, "Recursive stack cracker; Bug 24274");
ok ((q(a)x 100) =~ /^(??{'(.)'x 100})/,
- "Regexp /^(??{'(.)'x 100})/ crashes older perls");
+ "Regexp /^(??{'(.)'x 100})/ crashes older perls; Bug 24274");
}
-
{
# [perl #45337] utf8 + "[a]a{2}" + /$.../ = panic: sv_len_utf8 cache
- local $BugId = '45337';
+
local ${^UTF8CACHE} = -1;
- local $Message = "Shouldn't panic";
+ my $message = "Shouldn't panic; Bug 45337";
my $s = "[a]a{2}";
utf8::upgrade $s;
- ok "aaa" =~ /$s/;
+ like("aaa", qr/$s/, $message);
}
{
- local $BugId = '57042';
- local $Message = "Check if tree logic breaks \$^R";
+ my $message = "Check if tree logic breaks \$^R; Bug 57042";
my $cond_re = qr/\s*
\s* (?:
\( \s* A (?{1})
push @res, $^R ? "#$^R" : "UNDEF";
}
}
- iseq "@res","#1 #2";
+ is("@res","#1 #2", $message);
}
{
no warnings 'closure';
ok $2 eq "B";
}
-
-
# This only works under -DEBUGGING because it relies on an assert().
{
- local $BugId = '60508';
- local $Message = "Check capture offset re-entrancy of utf8 code.";
+ # Check capture offset re-entrancy of utf8 code.
sub fswash { $_[0] =~ s/([>X])//g; }
$k2 =~ s/([\360-\362])/>/g;
fswash($k2);
- iseq($k2, "\x{2022}", "utf8::SWASHNEW doesn't cause capture leaks");
+ is($k2, "\x{2022}", "utf8::SWASHNEW doesn't cause capture leaks; Bug 60508");
}
-
{
- local $BugId = 65372; # minimal CURLYM limited to 32767 matches
+ # minimal CURLYM limited to 32767 matches
my @pat = (
qr{a(x|y)*b}, # CURLYM
qr{a(x|y)*?b}, # .. with minmod
my $len = 32768;
my $s = join '', 'a', 'x' x $len, 'b';
for my $pat (@pat) {
- ok($s =~ $pat, $pat);
+ like($s, $pat, "$pat; Bug 65372");
}
}
+
+ {
+ local $::TODO = "[perl #38133]";
+
+ "A" =~ /(((?:A))?)+/;
+ my $first = $2;
+
+ "A" =~ /(((A))?)+/;
+ my $second = $2;
+
+ is($first, $second);
+ }
+
+ {
+ my $message
+ = 'utf8 =~ /trie/ where trie matches a continuation octet; Bug 70998';
+
+ # Catch warnings:
+ my $w;
+ local $SIG{__WARN__} = sub { $w .= shift };
+
+ # This bug can be reduced to
+ qq{\x{30ab}} =~ /\xab|\xa9/;
+ # but it's nice to have a more 'real-world' test. The original test
+ # case from the RT ticket follows:
+
+ my %conv = (
+ "\xab" => "<",
+ "\xa9" => "(c)",
+ );
+ my $conv_rx = '(' . join('|', map { quotemeta } keys %conv) . ')';
+ $conv_rx = qr{$conv_rx};
+
+ my $x
+ = qq{\x{3042}\x{304b}\x{3055}\x{305f}\x{306a}\x{306f}\x{307e}}
+ . qq{\x{3084}\x{3089}\x{308f}\x{3093}\x{3042}\x{304b}\x{3055}}
+ . qq{\x{305f}\x{306a}\x{306f}\x{307e}\x{3084}\x{3089}\x{308f}}
+ . qq{\x{3093}\x{30a2}\x{30ab}\x{30b5}\x{30bf}\x{30ca}\x{30cf}}
+ . qq{\x{30de}\x{30e4}\x{30e9}\x{30ef}\x{30f3}\x{30a2}\x{30ab}}
+ . qq{\x{30b5}\x{30bf}\x{30ca}\x{30cf}\x{30de}\x{30e4}\x{30e9}}
+ . qq{\x{30ef}\x{30f3}\x{30a2}\x{30ab}\x{30b5}\x{30bf}\x{30ca}}
+ . qq{\x{30cf}\x{30de}\x{30e4}\x{30e9}\x{30ef}\x{30f3}};
+
+ $x =~ s{$conv_rx}{$conv{$1}}eg;
+
+ is($w, undef, $message);
+ }
+
+ {
+ # minimal CURLYM limited to 32767 matches
+
+ is(join("-", " abc def " =~ /(?=(\S+))/g), "abc-bc-c-def-ef-f",
+ 'stclass optimisation does not break + inside (?=); Bug 68564');
+ }
+
+ {
+ use charnames ":full";
+ # Delayed interpolation of \N'
+ my $r1 = qr/\N{THAI CHARACTER SARA I}/;
+ my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}";
+
+ # Bug #56444
+ ok $s1 =~ /$r1+/, 'my $r1 = qr/\N{THAI CHARACTER SARA I}/; my $s1 = "\x{E34}\x{E34}\x{E34}\x{E34}; $s1 =~ /$r1+/';
+
+ # Bug #62056
+ ok "${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/, '"${s1}A" =~ m/$s1\N{LATIN CAPITAL LETTER A}/';
+
+ ok "abbbbc" =~ m/\N{1}/ && $& eq "a", '"abbbbc" =~ m/\N{1}/ && $& eq "a"';
+ ok "abbbbc" =~ m/\N{3,4}/ && $& eq "abbb", '"abbbbc" =~ m/\N{3,4}/ && $& eq "abbb"';
+ }
+
+ {
+ use charnames ":full";
+ my $message = '[perl #74982] Period coming after \N{}';
+ ok("\x{ff08}." =~ m/\N{FULLWIDTH LEFT PARENTHESIS}./ && $& eq "\x{ff08}.", $message);
+ ok("\x{ff08}." =~ m/[\N{FULLWIDTH LEFT PARENTHESIS}]./ && $& eq "\x{ff08}.", $message);
+ }
+
+SKIP: {
+ ######## "Segfault using HTML::Entities", Richard Jolly <richardjolly@mac.com>, <A3C7D27E-C9F4-11D8-B294-003065AE00B6@mac.com> in perl-unicode@perl.org
+
+ skip('Perl configured without Encode module', 1)
+ unless $Config{extensions} =~ / Encode /;
+
+ # Test case cut down by jhi
+ fresh_perl_like(<<'EOP', qr!Malformed UTF-8 character \(unexpected end of string\) in substitution \(s///\) at!, 'Segfault using HTML::Entities');
+use Encode;
+my $t = ord('A') == 193 ? "\xEA" : "\xE9";
+Encode::_utf8_on($t);
+$t =~ s/([^a])//ge;
+EOP
+ }
+
+ {
+ # pattern must be compiled late or we can break the test file
+ my $message = '[perl #115050] repeated nothings in a trie can cause panic';
+ my $pattern;
+ $pattern = '[xyz]|||';
+ ok("blah blah" =~ /$pattern/, $message);
+ ok("blah blah" =~ /(?:$pattern)h/, $message);
+ $pattern = '|||[xyz]';
+ ok("blah blah" =~ /$pattern/, $message);
+ ok("blah blah" =~ /(?:$pattern)h/, $message);
+ }
+
+ {
+ # [perl #4289] First mention $& after a match
+ fresh_perl_is(
+ '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"',
+ "b\n", {}, '$& first mentioned after match');
+ fresh_perl_is(
+ '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"',
+ "a\n", {}, '$` first mentioned after match');
+ fresh_perl_is(
+ '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$\'|,"\n"',
+ "c\n", {}, '$\' first mentioned after match');
+ }
} # End of sub run_tests
1;