X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F22-scalar-constants.t;fp=t%2F22-scalar-constants.t;h=c4a550b48507f58013aa6d6769308c63e3a5e27e;hb=05e35b66f2a12a2416a5964be485a4f741682a47;hp=0000000000000000000000000000000000000000;hpb=55716e9a7414ca5da96259d66fd0f20c1cbba893;p=perl%2Fmodules%2FLexical-Types.git diff --git a/t/22-scalar-constants.t b/t/22-scalar-constants.t new file mode 100644 index 0000000..c4a550b --- /dev/null +++ b/t/22-scalar-constants.t @@ -0,0 +1,36 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 6; + +use constant Str => 'MyTypes::Str'; +use constant Int => 'MyTypes::Int'; +use constant Num => 'MyTypes::Num'; + +sub MyTypes::Str::new { "str:$_[0]" } + +sub MyTypes::Int::new { "int:$_[0]" } + +{ package MyTypes::Num } + +{ + use Lexical::Types as => sub { $_[0] =~ /(?:Str|Int)/ ? ($_[0], 'new') : () }; + + my Str $x; + is $x, "str:MyTypes::Str", 'my constant_type $x'; + + my Int ($y, $z); + is $y, "int:MyTypes::Int", 'my constant_type ($y,'; + is $z, "int:MyTypes::Int", 'my constant_type $z)'; + + my Num $t; + is $t, undef, 'my constant_type_skipped $t'; + + my MyTypes::Str $u; + is $u, "str:MyTypes::Str", 'my MyTypes::Str $u'; + + my MyTypes::Num $v; + is $v, undef, 'my MyTypes::Num $v'; +}