From: Vincent Pit Date: Tue, 17 Mar 2009 00:26:38 +0000 (+0100) Subject: Test dieing in callbacks X-Git-Tag: v0.05~4 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=ad9c7ed2b44bcd7a122d716fc7a358ae645ee6da Test dieing in callbacks --- diff --git a/t/11-args.t b/t/11-args.t index 36047c5..eefa32e 100644 --- a/t/11-args.t +++ b/t/11-args.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 12 + 6; +use Test::More tests => 14 + 6; { package Lexical::Types::Test::LTT; @@ -24,6 +24,12 @@ use Test::More tests => 12 + 6; sub TYPEDSCALAR { 1 .. 2 } } +{ + package Lexical::Types::Test::LTT3; + + sub TYPEDSCALAR { die 'coconut' } +} + { package LTT; @@ -108,5 +114,26 @@ use Test::More tests => 12 + 6; like $@, $expect, 'as => code, initializing by returning two scalars'; } +{ + my $expect = qr/^banana at \(eval \d+\) line 2/; + diag 'This will throw two more warnings' if $] >= 5.008008 and $] < 5.009; + local $@; + eval q[ + use Lexical::Types as => sub { die 'banana' }; + my LTT $x; + ]; + like $@, $expect, 'as => sub { die }'; +} + +{ + my $expect = qr/^coconut at \Q$0\E line 30/; + local $@; + eval q[ + use Lexical::Types; + my Lexical::Types::Test::LTT3 $x; + ]; + like $@, $expect, 'die in TYPEDSCALAR'; +} + my LTT $x; is $x, undef, 'out of scope';