Commit | Line | Data |
39d38928 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
069668c4 |
4 | use Test::More tests => 5; |
39d38928 |
5 | use Test::Exception; |
6 | |
7 | do { |
8 | package Class; |
9 | use Mouse; |
10 | |
11 | has 'x'; |
12 | |
13 | has y => ( |
14 | is => 'ro', |
15 | ); |
16 | |
17 | has z => ( |
18 | is => 'rw', |
19 | ); |
20 | }; |
21 | |
22 | my $object = Class->new({x => 1, y => 2, z => 3}); |
23 | is($object->{x}, 1); |
24 | is($object->y, 2); |
25 | is($object->z, 3); |
26 | |
27 | throws_ok { |
28 | Class->new('non-hashref scalar'); |
29 | } qr/Single parameters to new\(\) must be a HASH ref/; |
30 | |
069668c4 |
31 | lives_ok { |
32 | Class->new(undef); |
33 | } "Class->new(undef) specifically doesn't throw an error. weird" |
34 | |