6 use Test::More tests => 4 + 3 + 1 + 2;
8 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
12 qr/^Indirect call of method "new" on object "$pkg" at \(eval \d+\) line \d+/;
18 local $SIG{__WARN__} = sub { push @warns, "@_" };
26 my $w1 = shift @warns;
27 my $w2 = shift @warns;
28 is $@, '', 'didn\'t croak without arguments';
29 like $w1, expect('Warn1'), 'first warning caught without arguments';
30 like $w2, expect('Warn2'), 'second warning caught without arguments';
31 is_deeply \@warns, [ ], 'no more warnings without arguments';
34 for my $fatal (':fatal', 'FATAL', ':Fatal') {
36 local $SIG{__WARN__} = sub { die "warn:@_" };
38 die qq{shouldn't even compile\n};
44 like $@, expect('Croaked'), "croaks when $fatal is specified";
49 local $SIG{__WARN__} = sub { "warn:@_" };
51 die qq{shouldn't even compile\n};
52 no indirect 'whatever', hook => sub { die 'hook:' . join(':', @_) . "\n" };
54 $x = new AlsoNotReached;
57 like $@, qr/^hook:Hooked:new:\(eval\s+\d+\):\d+$/, 'calls the specified hook';
61 my $no_hook_and_fatal = qr/^The 'fatal' and 'hook' options are mutually exclusive at \(eval \d+\) line \d+/;
64 local $SIG{__WARN__} = sub { die "warn:@_" };
66 die qq{shouldn't even compile\n};
67 no indirect 'fatal', hook => sub { };
71 like $@, $no_hook_and_fatal, '"no indirect qw<fatal hook>" croaks';
74 local $SIG{__WARN__} = sub { die "warn:@_" };
76 die qq{shouldn't even compile\n};
77 no indirect hook => sub { }, 'fatal';
81 like $@, $no_hook_and_fatal, '"no indirect qw<hook fatal>" croaks';