X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=t%2F10-args.t;h=a049ea765b1b01eb1ff4e53df1f7c090474e3634;hb=refs%2Ftags%2Fv0.16;hp=dddcea9b446ced080c33303d3b19dc6ad60fc6dd;hpb=06cb3f3506161a118dc440264dcabcd612b9432c;p=perl%2Fmodules%2FLexical-Types.git
diff --git a/t/10-args.t b/t/10-args.t
index dddcea9..a049ea7 100644
--- a/t/10-args.t
+++ b/t/10-args.t
@@ -3,13 +3,14 @@
use strict;
use warnings;
-use Test::More tests => 11 + 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 => 11 + 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
}
@@ -47,6 +54,12 @@ use Test::More tests => 11 + 6;
is $x, __LINE__-1, 'as => string, with trailing ::';
}
+{
+ use Lexical::Types as => sub { return };
+ my LTT $x;
+ is $x, undef, 'as => code, returning nothing';
+}
+
{
use Lexical::Types as => sub { 'Lexical::Types::Test::LTT' };
my LTT $x;
@@ -75,7 +88,7 @@ use Test::More tests => 11 + 6;
my $expect = qr/^Invalid ARRAY reference/;
local $@;
eval q[
- use Lexical::Types as => [ qw/a b c/ ];
+ use Lexical::Types as => [ qw ];
my LTT $x;
];
like $@, $expect, 'as => array';
@@ -83,10 +96,10 @@ use Test::More tests => 11 + 6;
{
my $expect = qr/^Lexical::Types mangler should return zero, one or two scalars, but got 3/;
- diag 'This will throw two warnings' if $] >= 5.008008 and $] < 5.009;
+ diag 'This will throw two warnings' if "$]" >= 5.008_008 and "$]" < 5.009;
local $@;
eval q[
- use Lexical::Types as => sub { qw/a b c/ };
+ use Lexical::Types as => sub { qw };
my LTT $x;
];
like $@, $expect, 'as => code, returning three scalars';
@@ -102,5 +115,26 @@ use Test::More tests => 11 + 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.008_008 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';