X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-args.t;h=444c730f49334bf0f726c50ca3894ff88652fcfe;hb=faa0984a60b4134d0556ed7e6225bf83ddfb5474;hp=6b7b61c2b0d97a3cf90954a027fbdbcb0803e50c;hpb=50cf1763d6570e6589e3e809aede60d7e3f1912e;p=perl%2Fmodules%2Findirect.git diff --git a/t/10-args.t b/t/10-args.t index 6b7b61c..444c730 100644 --- a/t/10-args.t +++ b/t/10-args.t @@ -1,17 +1,82 @@ -#!perl +#!perl -T use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 4 + 3 + 1 + 2; + +BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } + +sub expect { + my ($pkg) = @_; + qr/^Indirect call of method "new" on object "$pkg" at \(eval \d+\) line \d+/; +} { - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - eval < 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'; }