Update tests
[gitmo/Mouse.git] / t / 040_type_constraints / 025_type_coersion_on_lazy_attributes.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 1;
7
8 {
9     package SomeClass;
10     use Mouse;
11     use Mouse::Util::TypeConstraints;
12
13     subtype 'DigitSix' => as 'Num'
14         => where { /^6$/ };
15     subtype 'TextSix' => as 'Str'
16         => where { /Six/i };
17
18     coerce 'TextSix'
19         => from 'DigitSix'
20         => via { confess("Cannot live without 6 ($_)") unless /^6$/; 'Six' };
21
22     has foo => (
23         is      => 'ro',
24         isa     => 'TextSix',
25         coerce  => 1,
26         default => 6,
27         lazy    => 1
28     );
29 }
30
31 is(SomeClass->new()->foo, 'Six');
32
33