bug fixed: BUILD method doesn't works
[gitmo/Mouse.git] / t / 800_shikabased / 003-make_immutable.t
1 use strict;
2 use warnings;
3 use Test::More tests => 6;
4 use Test::Exception;
5
6 {
7     package HardDog;
8     use Mouse;
9     has bone => (
10         is => 'rw',
11         required => 1,
12     );
13     sub BUILD { main::ok "calling BUILD in HardDog" }
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     );
25     sub BUILD { main::ok "calling BUILD in SoftDog" }
26     no Mouse;
27 }
28
29 lives_ok { SoftDog->new(bone => 'moo') };
30 lives_ok { HardDog->new(bone => 'moo') };
31
32 throws_ok { SoftDog->new() } qr/\QAttribute (bone) is required/;
33 throws_ok { HardDog->new() } qr/\QAttribute (bone) is required/;
34