Commit | Line | Data |
86629f93 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
9c434902 |
6 | use Test::More tests => 8; |
86629f93 |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose::Util::TypeConstraints'); |
11 | } |
12 | |
13 | # subtype 'aliasing' ... |
14 | |
15 | lives_ok { |
16 | subtype 'Numb3rs' => as 'Num'; |
17 | } '... create bare subtype fine'; |
18 | |
19 | my $numb3rs = find_type_constraint('Numb3rs'); |
9c434902 |
20 | isa_ok($numb3rs, 'Moose::Meta::TypeConstraint'); |
21 | |
22 | # subtype with unions |
23 | |
24 | { |
25 | package Test::Moose::Meta::TypeConstraint::Union; |
26 | |
27 | use overload '""' => sub { 'Broken|Test' }, fallback => 1; |
28 | use Moose; |
29 | |
30 | extends 'Moose::Meta::TypeConstraint'; |
31 | } |
32 | |
33 | ok my $dummy_instance = Test::Moose::Meta::TypeConstraint::Union->new |
34 | => "Created Instance"; |
35 | |
36 | isa_ok $dummy_instance, 'Test::Moose::Meta::TypeConstraint::Union' |
37 | => 'isa correct type'; |
38 | |
39 | is "$dummy_instance", "Broken|Test" |
40 | => "Got expected stringification result"; |
41 | |
42 | ok my $subtype1 = subtype('New1', as $dummy_instance) |
43 | => "made a subtype"; |
44 | |
45 | ok my $subtype2 = subtype('New2', as $subtype1) |
46 | => "made another subtype"; |