bug fixed: BUILD method doesn't works
[gitmo/Mouse.git] / t / 800_shikabased / 003-make_immutable.t
CommitLineData
fc1d8369 1use strict;
2use warnings;
63d74d7a 3use Test::More tests => 6;
eab81545 4use Test::Exception;
fc1d8369 5
6{
7 package HardDog;
8 use Mouse;
9 has bone => (
10 is => 'rw',
11 required => 1,
12 );
63d74d7a 13 sub BUILD { main::ok "calling BUILD in HardDog" }
fc1d8369 14 no Mouse;
15 __PACKAGE__->meta->make_immutable;
16}
17
18{
19 package SoftDog;
20 use Mouse;
21 has bone => (
22 is => 'rw',
23 required => 1,
24 );
63d74d7a 25 sub BUILD { main::ok "calling BUILD in SoftDog" }
fc1d8369 26 no Mouse;
27}
28
29lives_ok { SoftDog->new(bone => 'moo') };
30lives_ok { HardDog->new(bone => 'moo') };
31
32throws_ok { SoftDog->new() } qr/\QAttribute (bone) is required/;
33throws_ok { HardDog->new() } qr/\QAttribute (bone) is required/;
34