Commit | Line | Data |
62225dfe |
1 | #!/usr/bin/perl |
5a592ad7 |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
62225dfe |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
5a592ad7 |
9 | use Test::More; |
62225dfe |
10 | |
11 | { |
12 | package SomeClass; |
13 | use Mouse; |
14 | use Mouse::Util::TypeConstraints; |
15 | |
16 | subtype 'DigitSix' => as 'Num' |
17 | => where { /^6$/ }; |
18 | subtype 'TextSix' => as 'Str' |
19 | => where { /Six/i }; |
62225dfe |
20 | coerce 'TextSix' |
21 | => from 'DigitSix' |
22 | => via { confess("Cannot live without 6 ($_)") unless /^6$/; 'Six' }; |
23 | |
24 | has foo => ( |
25 | is => 'ro', |
26 | isa => 'TextSix', |
27 | coerce => 1, |
28 | default => 6, |
29 | lazy => 1 |
30 | ); |
31 | } |
32 | |
5a592ad7 |
33 | my $attr = SomeClass->meta->get_attribute('foo'); |
34 | is($attr->get_value(SomeClass->new()), 'Six'); |
62225dfe |
35 | is(SomeClass->new()->foo, 'Six'); |
36 | |
5a592ad7 |
37 | done_testing; |