6 use Test::More tests => 5 + 4;
11 BEGIN { require Lexical::Types; }
14 eval 'package Str; package Int';
15 Lexical::Types->import(
16 as => sub { __PACKAGE__, 'new_' . lc($_[0]) }
21 Lexical::Types->unimport;
25 $_[1] = 'str:' . (caller(0))[2];
26 Test::More::is($_[2], 'Str', 'original type is correct');
31 $_[1] = (caller(0))[2];
32 Test::More::is($_[2], 'Int', 'original type is correct');
38 BEGIN { MyTypes->import }
40 is $x, 'str:' . (__LINE__-1), 'MyTypes->new_str 1';
42 BEGIN { MyTypes->unimport }
44 is $y, undef, 'pragma not in use';
46 BEGIN { MyTypes->import }
48 is $z, __LINE__-1, 'MyTypes->new_int 1';
52 is $y, 'str:' . (__LINE__-1), 'MyTypes->new_str 2';
54 is $z, __LINE__-1, 'MyTypes->new_int 2';