Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 040_type_constraints / 025_type_coersion_on_lazy_attributes.t
1 #!/usr/bin/perl
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;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
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 };
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
33 my $attr = SomeClass->meta->get_attribute('foo');
34 is($attr->get_value(SomeClass->new()), 'Six');
35 is(SomeClass->new()->foo, 'Six');
36
37 done_testing;