Commit | Line | Data |
39d38928 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
c9aefe26 |
4 | use Test::More tests => 7; |
eab81545 |
5 | use Test::Exception; |
39d38928 |
6 | |
7 | do { |
8 | package Class; |
9 | use Mouse; |
10 | |
74be9f76 |
11 | has x => ( |
12 | is => 'bare', |
13 | ); |
39d38928 |
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 | |
c9aefe26 |
33 | throws_ok { |
069668c4 |
34 | Class->new(undef); |
c9aefe26 |
35 | } qr/Single parameters to new\(\) must be a HASH ref/; |
36 | |
37 | Class->meta->make_immutable; |
38 | |
39 | throws_ok { |
40 | Class->new('non-hashref scalar'); |
41 | } qr/Single parameters to new\(\) must be a HASH ref/; |
069668c4 |
42 | |
c9aefe26 |
43 | throws_ok { |
44 | Class->new(undef); |
45 | } qr/Single parameters to new\(\) must be a HASH ref/; |