X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-args.t;h=26aa4b6335d89f1f2bdba3752e508432adc3fa01;hb=96041514c33f571bb0f3b8bb7e04b7f9ff6fe17a;hp=879dadd04deda260b7d1ad2e7f8ce52ae6436119;hpb=b99618b6940bc947b829ddfdb23b5bb69a2e8e98;p=perl%2Fmodules%2FLexical-Types.git diff --git a/t/11-args.t b/t/11-args.t index 879dadd..26aa4b6 100644 --- a/t/11-args.t +++ b/t/11-args.t @@ -3,13 +3,14 @@ use strict; use warnings; -use Test::More tests => 12 + 6; +use Test::More tests => 14 + 6; { package Lexical::Types::Test::LTT; sub TYPEDSCALAR { $_[1] = (caller(0))[2]; + local $Test::Builder::Level = $Test::Builder::Level + 1; Test::More::is($_[2], 'LTT', 'original type is ok'); (); } @@ -24,9 +25,15 @@ use Test::More tests => 12 + 6; sub TYPEDSCALAR { 1 .. 2 } } +{ + package Lexical::Types::Test::LTT3; + + sub TYPEDSCALAR { die 'coconut' } +} + { package LTT; - + no warnings 'once'; *ts = \&Lexical::Types::Test::LTT::TYPEDSCALAR } @@ -108,5 +115,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 31/; + 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';