Format Changes
[gitmo/Mouse.git] / t / 001_mouse / 029-new.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 7;
5 use Test::Exception;
6
7 do {
8     package Class;
9     use Mouse;
10
11     has x => (
12         is => 'bare',
13     );
14
15     has y => (
16         is => 'ro',
17     );
18
19     has z => (
20         is => 'rw',
21     );
22 };
23
24 my $object = Class->new({x => 1, y => 2, z => 3});
25 is($object->{x}, 1);
26 is($object->y, 2);
27 is($object->z, 3);
28
29 throws_ok {
30     Class->new('non-hashref scalar');
31 } qr/Single parameters to new\(\) must be a HASH ref/;
32
33 throws_ok {
34     Class->new(undef);
35 } qr/Single parameters to new\(\) must be a HASH ref/;
36
37 Class->meta->make_immutable;
38
39 throws_ok {
40     Class->new([]);
41 } qr/Single parameters to new\(\) must be a HASH ref/;
42
43 throws_ok {
44     Class->new(Class->new);
45 } qr/Single parameters to new\(\) must be a HASH ref/;