}
try { ... }; # warns
- no indirect ':fatal';
+ no indirect ':fatal'; # or 'FATAL', or ':Fatal' ...
if (defied $foo) { ... } # croaks, note the typo
# From the command-line
=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.
=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 *
my $arg = shift;
if ($arg eq 'hook') {
$hook = shift;
- } elsif ($arg eq ':fatal') {
+ } elsif ($arg =~ /^:?fatal$/i) {
$hook = sub { die msg(@_) };
}
last if $hook;
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} }
is_deeply \@warns, [ ], 'no more warnings without arguments';
}
-{
+for my $fatal (':fatal', 'FATAL', ':Fatal') {
{
local $SIG{__WARN__} = sub { die "warn:@_" };
- eval <<' HERE';
+ eval <<" HERE";
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
}
- like $@, expect('Croaked'), 'croaks when :fatal is specified';
+ like $@, expect('Croaked'), "croaks when $fatal is specified";
}
{