Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 040_type_constraints / 025_type_coersion_on_lazy_attributes.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
62225dfe 5
6use strict;
7use warnings;
8
5a592ad7 9use 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 33my $attr = SomeClass->meta->get_attribute('foo');
34is($attr->get_value(SomeClass->new()), 'Six');
62225dfe 35is(SomeClass->new()->foo, 'Six');
36
5a592ad7 37done_testing;