Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More tests => 10; |
eab81545 |
5 | use Test::Exception; |
c3398f5b |
6 | |
7 | do { |
8 | package Class; |
9 | use Mouse; |
10 | |
74be9f76 |
11 | has 'x' => ( |
12 | is => 'bare', |
13 | ); |
c3398f5b |
14 | |
15 | has 'y' => ( |
16 | is => 'ro', |
17 | ); |
18 | |
19 | has 'z' => ( |
20 | is => 'rw', |
21 | ); |
22 | }; |
23 | |
24 | ok(!Class->can('x'), "No accessor is injected if 'is' has no value"); |
25 | can_ok('Class', 'y', 'z'); |
26 | |
27 | my $object = Class->new; |
28 | |
29 | ok(!$object->can('x'), "No accessor is injected if 'is' has no value"); |
30 | can_ok($object, 'y', 'z'); |
31 | |
32 | is($object->y, undef); |
636c002e |
33 | |
34 | throws_ok { |
35 | $object->y(10); |
36 | } qr/Cannot assign a value to a read-only accessor/; |
37 | |
c3398f5b |
38 | is($object->y, undef); |
39 | |
40 | is($object->z, undef); |
41 | is($object->z(10), 10); |
42 | is($object->z, 10); |
43 | |