add begin.t from Method::Signatures
[p5sagit/Function-Parameters.git] / t / foreign / MooseX-Method-Signatures / type_alias.t
1 #!perl
2 use strict;
3 use warnings FATAL => 'all';
4 use Test::More
5     eval { require Moose; require aliased }
6     ? (tests => 2)
7     : (skip_all => "Moose, aliased required for testing types")
8 ;
9 use Test::Fatal;
10
11 use Dir::Self;
12 use lib __DIR__ . '/lib';
13
14 {
15     package TestClass;
16     use Moose;
17     use Function::Parameters qw(:strict);
18
19     use aliased 'My::Annoyingly::Long::Name::Space', 'Shortcut';
20
21     ::is(::exception { method alias_sig ((Shortcut) $affe) { } },
22         undef, 'method with aliased type constraint compiles');
23 }
24
25 my $o = TestClass->new;
26 my $affe = My::Annoyingly::Long::Name::Space->new;
27
28 is(exception {
29     $o->alias_sig($affe);
30 }, undef, 'calling method with aliased type constraint');
31