From: Vincent Pit Date: Wed, 15 Jul 2009 16:54:51 +0000 (+0200) Subject: Freshen t/10-args.t X-Git-Tag: v0.17~3 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=540837c786e360ce093b9d1fcb93cf7614ac0307;p=perl%2Fmodules%2Findirect.git Freshen t/10-args.t --- diff --git a/t/10-args.t b/t/10-args.t index 683b57e..d735295 100644 --- a/t/10-args.t +++ b/t/10-args.t @@ -7,44 +7,50 @@ use Test::More tests => 4 + 1 + 1; sub expect { my ($pkg) = @_; - return qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"$pkg"\s+at\s+\(eval\s+\d+\)\s+line\s+\d+/; + qr/^Indirect call of method "new" on object "$pkg" at \(eval \d+\) line \d+/; } { my @warns; - local $SIG{__WARN__} = sub { push @warns, "@_" }; - eval <<'HERE'; - die qq{ok\n}; - no indirect; - my $x = new Warn1; - $x = new Warn2; -HERE + { + local $SIG{__WARN__} = sub { push @warns, "@_" }; + eval <<' HERE'; + return; + no indirect; + my $x = new Warn1; + $x = new Warn2; + HERE + } my $w1 = shift @warns; my $w2 = shift @warns; - is $@, "ok\n", 'didn\'t croak without arguments'; + is $@, '', 'didn\'t croak without arguments'; like $w1, expect('Warn1'), 'first warning caught without arguments'; like $w2, expect('Warn2'), 'second warning caught without arguments'; is_deeply \@warns, [ ], 'no more warnings without arguments'; } { - 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' }; - my $x = new Croaked; - $x = new NotReached; -HERE + { + 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' }; + my $x = new Croaked; + $x = new NotReached; + HERE + } like $@, expect('Croaked'), 'croaks when :fatal is specified'; } { - local $SIG{__WARN__} = sub { "warn:@_" }; - eval <<'HERE'; - die qq{shouldn't even compile\n}; - no indirect 'whatever', hook => sub { die 'hook:' . join(':', @_) . "\n" }, ':fatal'; - my $x = new Hooked; - $x = new AlsoNotReached; -HERE + { + local $SIG{__WARN__} = sub { "warn:@_" }; + eval <<' HERE'; + die qq{shouldn't even compile\n}; + no indirect 'whatever', hook => sub { die 'hook:' . join(':', @_) . "\n" }, ':fatal'; + my $x = new Hooked; + $x = new AlsoNotReached; + HERE + } like $@, qr/^hook:Hooked:new:\(eval\s+\d+\):\d+$/, 'calls the specified hook'; }