X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=t%2F10-args.t;h=444c730f49334bf0f726c50ca3894ff88652fcfe;hp=bacf850354c9860a801942be79fbaa946ba84168;hb=75a60b70d39a18521fcf5c2fbc7266100da27110;hpb=5da717399870f32544637bd4068e00e01eab84a2 diff --git a/t/10-args.t b/t/10-args.t index bacf850..444c730 100644 --- a/t/10-args.t +++ b/t/10-args.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 4 + 3 + 1; +use Test::More tests => 4 + 3 + 1 + 2; BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } @@ -36,7 +36,7 @@ for my $fatal (':fatal', 'FATAL', ':Fatal') { local $SIG{__WARN__} = sub { die "warn:@_" }; eval <<" HERE"; die qq{shouldn't even compile\n}; - no indirect '$fatal', hook => sub { die 'should not be called' }; + no indirect '$fatal'; my \$x = new Croaked; \$x = new NotReached; HERE @@ -49,10 +49,34 @@ for my $fatal (':fatal', 'FATAL', ':Fatal') { local $SIG{__WARN__} = sub { "warn:@_" }; eval <<' HERE'; die qq{shouldn't even compile\n}; - no indirect 'whatever', hook => sub { die 'hook:' . join(':', @_) . "\n" }, ':fatal'; + no indirect 'whatever', hook => sub { die 'hook:' . join(':', @_) . "\n" }; my $x = new Hooked; $x = new AlsoNotReached; HERE } like $@, qr/^hook:Hooked:new:\(eval\s+\d+\):\d+$/, 'calls the specified hook'; } + +{ + my $no_hook_and_fatal = qr/^The 'fatal' and 'hook' options are mutually exclusive at \(eval \d+\) line \d+/; + + { + local $SIG{__WARN__} = sub { die "warn:@_" }; + eval <<' HERE'; + die qq{shouldn't even compile\n}; + no indirect 'fatal', hook => sub { }; + new NotReached; + HERE + } + like $@, $no_hook_and_fatal, '"no indirect qw" croaks'; + + { + local $SIG{__WARN__} = sub { die "warn:@_" }; + eval <<' HERE'; + die qq{shouldn't even compile\n}; + no indirect hook => sub { }, 'fatal'; + new NotReached; + HERE + } + like $@, $no_hook_and_fatal, '"no indirect qw" croaks'; +}