Permalink
Browse files

tests for using aliased.pm with type signatures

  • Loading branch information...
1 parent 1929314 commit 37f7e16306430ecc8632ae85f8c6af0fa69dbe80 @renormalist renormalist committed Aug 17, 2009
Showing with 47 additions and 0 deletions.
  1. +2 −0 t/lib/Another/AnnoyingTypeName/Bbb.pm
  2. +2 −0 t/lib/My/AnnoyinglyLongTypeName/Aaa.pm
  3. +43 −0 t/type_alias.t
@@ -0,0 +1,2 @@
+package Another::AnnoyingTypeName::Bbb;
+1;
@@ -0,0 +1,2 @@
+package My::AnnoyinglyLongTypeName::Aaa;
+1;
View
@@ -0,0 +1,43 @@
+use strict;
+use warnings;
+use Test::More tests => 9;
+use Test::Exception;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+{
+ package TestClass;
+ use MooseX::Method::Signatures;
+
+ use aliased 'My::AnnoyinglyLongTypeName::Aaa';
+ use Another::AnnoyingTypeName::Bbb;
+
+ method a (My::AnnoyinglyLongTypeName::Aaa $affe) { }
+ method a2 (Aaa $loewe) { 'me_is_the_goal' }
+ method b (Another::AnnoyingTypeName::Bbb $tiger) { }
+}
+
+use aliased "My::AnnoyinglyLongTypeName::Aaa";
+use Another::AnnoyingTypeName::Bbb;
+
+my $aaa = bless {} => 'My::AnnoyinglyLongTypeName::Aaa';
+my $aaa_aliased = bless {} => Aaa;
+my $bbb = bless {} => 'Another::AnnoyingTypeName::Bbb';
+my $bbb_thewrongway = bless {} => 'Bbb';
+
+my $o = TestClass->new;
+
+lives_ok( sub { $o->a($aaa) });
+lives_ok( sub { $o->a2($aaa) });
+
+lives_ok( sub { $o->a($aaa_aliased) });
+lives_ok( sub { $o->a2($aaa_aliased) });
+
+dies_ok( sub { $o->b($aaa) });
+dies_ok( sub { $o->b($aaa_aliased) });
+
+lives_ok( sub { $o->b($bbb) });
+dies_ok( sub { $o->b($bbb_thewrongway) });
+
+is( $o->a2($aaa_aliased), 'me_is_the_goal', "all features in one go");

0 comments on commit 37f7e16

Please sign in to comment.