]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Allow /^:?fatal$/ to specify the lethal behaviour rt59498
authorVincent Pit <vince@profvince.com>
Mon, 16 Aug 2010 13:09:38 +0000 (15:09 +0200)
committerVincent Pit <vince@profvince.com>
Mon, 16 Aug 2010 13:16:00 +0000 (15:16 +0200)
This fixes RT #59498.

lib/indirect.pm
t/10-args.t

index 239773f9a6d7b65c66394f290151786db027ef06..6cdf32af8d871ccb9999d67d7ddc5836c4acb3c3 100644 (file)
@@ -35,7 +35,7 @@ BEGIN {
     }
     try { ... }; # warns
 
     }
     try { ... }; # warns
 
-    no indirect ':fatal';
+    no indirect ':fatal';    # or 'FATAL', or ':Fatal' ...
     if (defied $foo) { ... } # croaks, note the typo
 
     # From the command-line
     if (defied $foo) { ... } # croaks, note the typo
 
     # From the command-line
@@ -72,7 +72,7 @@ BEGIN {
 
 =head1 METHODS
 
 
 =head1 METHODS
 
-=head2 C<< unimport [ hook => $hook | ':fatal' ] >>
+=head2 C<< unimport [ hook => $hook | ':fatal', 'FATAL', ... ] >>
 
 Magically called when C<no indirect @opts> is encountered.
 Turns the module on.
 
 Magically called when C<no indirect @opts> is encountered.
 Turns the module on.
@@ -82,7 +82,7 @@ The policy to apply depends on what is first found in C<@opts> :
 
 =item *
 
 
 =item *
 
-If it's the string C<':fatal'>, the compilation will croak on the first indirect syntax met.
+If it is a string that matches C</^:?fatal$/i>, the compilation will croak on the first indirect syntax met.
 
 =item *
 
 
 =item *
 
@@ -105,7 +105,7 @@ sub unimport {
   my $arg = shift;
   if ($arg eq 'hook') {
    $hook = shift;
   my $arg = shift;
   if ($arg eq 'hook') {
    $hook = shift;
-  } elsif ($arg eq ':fatal') {
+  } elsif ($arg =~ /^:?fatal$/i) {
    $hook = sub { die msg(@_) };
   }
   last if $hook;
    $hook = sub { die msg(@_) };
   }
   last if $hook;
index 4037c60eb95231591255b08f4c613dfc46b64018..bacf850354c9860a801942be79fbaa946ba84168 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-use Test::More tests => 4 + 1 + 1;
+use Test::More tests => 4 + 3 + 1;
 
 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
 
 
 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
 
@@ -31,17 +31,17 @@ sub expect {
  is_deeply \@warns, [ ],             'no more warnings without arguments';
 }
 
  is_deeply \@warns, [ ],             'no more warnings without arguments';
 }
 
-{
+for my $fatal (':fatal', 'FATAL', ':Fatal') {
  {
   local $SIG{__WARN__} = sub { die "warn:@_" };
  {
   local $SIG{__WARN__} = sub { die "warn:@_" };
-  eval <<'  HERE';
+  eval <<"  HERE";
    die qq{shouldn't even compile\n};
    die qq{shouldn't even compile\n};
-   no indirect ':fatal', hook => sub { die 'should not be called' };
-   my $x = new Croaked;
-   $x = new NotReached;
+   no indirect '$fatal', hook => sub { die 'should not be called' };
+   my \$x = new Croaked;
+   \$x = new NotReached;
   HERE
  }
   HERE
  }
- like $@, expect('Croaked'), 'croaks when :fatal is specified';
+ like $@, expect('Croaked'), "croaks when $fatal is specified";
 }
 
 {
 }
 
 {