Update tests
[gitmo/Mouse.git] / t / 040_type_constraints / 025_type_coersion_on_lazy_attributes.t
CommitLineData
62225dfe 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use 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
31is(SomeClass->new()->foo, 'Six');
32
33