# the format supported by op/regexp.t. If you want to add a test
# that does fit that format, add it to op/re_tests, not here.
-print "1..207\n";
+print "1..213\n";
BEGIN {
chdir 't' if -d 't';
print "ok $test\n";
$test++;
+print "not " unless "abc" =~ /^(??{"a"})b/;
+print "ok $test\n";
+$test++;
+
my $matched;
-$matched = qr/\((?:(?>[^()]+)|(?p{$matched}))*\)/;
+$matched = qr/\((?:(?>[^()]+)|(??{$matched}))*\)/;
@ans = @ans1 = ();
push(@ans, $res), push(@ans1, $&) while $res = m/$matched/g;
sub must_warn {
my ($warn_pat, $code) = @_;
- local $^W; local %SIG;
- eval 'BEGIN { $^W = 1; $SIG{__WARN__} = $warn_pat };' . $code;
+ local %SIG;
+ eval 'BEGIN { use warnings; $SIG{__WARN__} = $warn_pat };' . $code;
print "ok $test\n";
$test++;
}
$test++;
$brackets = qr{
- { (?> [^{}]+ | (?p{ $brackets }) )* }
+ { (?> [^{}]+ | (??{ $brackets }) )* }
}x;
"{{}" =~ $brackets;
print "ok $test\n"; # Did we survive?
$test++;
-"something { long { and } hairy" =~ m/((?p{ $brackets }))/;
+"something { long { and } hairy" =~ m/((??{ $brackets }))/;
print "not " unless $1 eq "{ and }";
print "ok $test\n";
$test++;
$test++;
@a = map chr,0..255;
-print "not " if grep(/\S/,@a) != grep(/[^\s]/,@a);
+
+@b = grep(/\S/,@a);
+@c = grep(/[^\s]/,@a);
+print "not " if "@b" ne "@c";
+print "ok $test\n";
+$test++;
+
+@b = grep(/\S/,@a);
+@c = grep(/[\S]/,@a);
+print "not " if "@b" ne "@c";
+print "ok $test\n";
+$test++;
+
+@b = grep(/\s/,@a);
+@c = grep(/[^\S]/,@a);
+print "not " if "@b" ne "@c";
+print "ok $test\n";
+$test++;
+
+@b = grep(/\s/,@a);
+@c = grep(/[\s]/,@a);
+print "not " if "@b" ne "@c";
+print "ok $test\n";
+$test++;
+
+@b = grep(/\D/,@a);
+@c = grep(/[^\d]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\S/,@a) != grep(/[\S]/,@a);
+@b = grep(/\D/,@a);
+@c = grep(/[\D]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\s/,@a) != grep(/[^\S]/,@a);
+@b = grep(/\d/,@a);
+@c = grep(/[^\D]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\s/,@a) != grep(/[\s]/,@a);
+@b = grep(/\d/,@a);
+@c = grep(/[\d]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\D/,@a) != grep(/[^\d]/,@a);
+@b = grep(/\W/,@a);
+@c = grep(/[^\w]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\D/,@a) != grep(/[\D]/,@a);
+@b = grep(/\W/,@a);
+@c = grep(/[\W]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\d/,@a) != grep(/[^\D]/,@a);
+@b = grep(/\w/,@a);
+@c = grep(/[^\W]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\d/,@a) != grep(/[\d]/,@a);
+@b = grep(/\w/,@a);
+@c = grep(/[\w]/,@a);
+print "not " if "@b" ne "@c";
print "ok $test\n";
$test++;
-print "not " if grep(/\W/,@a) != grep(/[^\w]/,@a);
+# see if backtracking optimization works correctly
+"\n\n" =~ /\n $ \n/x or print "not ";
print "ok $test\n";
$test++;
-print "not " if grep(/\W/,@a) != grep(/[\W]/,@a);
+"\n\n" =~ /\n* $ \n/x or print "not ";
print "ok $test\n";
$test++;
-print "not " if grep(/\w/,@a) != grep(/[^\W]/,@a);
+"\n\n" =~ /\n+ $ \n/x or print "not ";
print "ok $test\n";
$test++;
-print "not " if grep(/\w/,@a) != grep(/[\w]/,@a);
+[] =~ /^ARRAY/ or print "# [] \nnot ";
+print "ok $test\n";
+$test++;
+
+eval << 'EOE';
+{
+ package S;
+ use overload '""' => sub { 'Object S' };
+ sub new { bless [] }
+}
+$a = 'S'->new;
+EOE
+
+$a and $a =~ /^Object\sS/ or print "# '$a' \nnot ";
print "ok $test\n";
$test++;