This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate the global override $DiePattern from t/re{ReTest.pl,pat.t}
authorNicholas Clark <nick@ccl4.org>
Thu, 3 Mar 2011 11:44:46 +0000 (11:44 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 3 Mar 2011 11:44:46 +0000 (11:44 +0000)
For the only user of this, instead explicitly pass the value into must_die()
As must_die() is always passed $name, eliminate its use of $Message.

t/re/ReTest.pl
t/re/pat.t

index 1d19185..be556d6 100644 (file)
@@ -11,7 +11,6 @@ use vars qw(
     $EXPECTED_TESTS 
     $TODO
     $Message
-    $DiePattern
     $WarnPattern
     $BugId
     $running_as_thread
@@ -158,12 +157,11 @@ sub eval_ok ($;$) {
 
 sub must_die {
     my ($code, $pattern, $name) = @_;
-    $pattern //= $DiePattern
-        or Carp::confess("Bad pattern");
+    Carp::confess("Bad pattern") unless $pattern;
     undef $@;
     ref $code ? &$code : eval $code;
     my  $r = $@ && $@ =~ /$pattern/;
-    _ok $r, $name // $Message // "\$\@ =~ /$pattern/";
+    _ok $r, $name // "\$\@ =~ /$pattern/";
 }
 
 sub must_warn {
index f344402..bdfff05 100644 (file)
@@ -590,12 +590,12 @@ sub run_tests {
 
     {
         must_die 'q(a:[b]:) =~ /[x[:foo:]]/',
-                 'POSIX class \[:[^:]+:\] unknown in regex',
+                 qr/POSIX class \[:[^:]+:\] unknown in regex/,
                  'POSIX class [: :] must have valid name';
 
         for my $d (qw [= .]) {
             must_die "/[[${d}foo${d}]]/",
-                     "\QPOSIX syntax [$d $d] is reserved for future extensions",
+                     qr/\QPOSIX syntax [$d $d] is reserved for future extensions/,
                      "POSIX syntax [[$d $d]] is an error";
         }
     }
@@ -683,13 +683,9 @@ sub run_tests {
     }
 
 
-    {
-        local $DiePattern = '^Modification of a read-only value attempted';
-        local $Message    = 'Elements of @- and @+ are read-only';
-        must_die '$+[0] = 13';
-        must_die '$-[0] = 13';
-        must_die '@+ = (7, 6, 5)';
-        must_die '@- = qw (foo bar)';
+    foreach ('$+[0] = 13', '$-[0] = 13', '@+ = (7, 6, 5)', '@- = qw (foo bar)') {
+        must_die($_, qr/^Modification of a read-only value attempted/,
+                'Elements of @- and @+ are read-only');
     }