Commit | Line | Data |
7e2909e5 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
a02698f1 |
4 | use Test::More tests => 3; |
eab81545 |
5 | use Test::Exception; |
7e2909e5 |
6 | |
7 | do { |
8 | package Class; |
9 | use Mouse; |
10 | |
11 | has attr => ( |
12 | is => 'rw', |
13 | isa => 'Bool', |
14 | ); |
15 | |
16 | package Child; |
17 | use Mouse; |
18 | extends 'Class'; |
19 | |
20 | has '+attr' => ( |
21 | default => 1, |
22 | ); |
23 | }; |
24 | |
25 | my $obj = Class->new; |
26 | ok(!$obj->attr, 'has + does not affect the superclass'); |
27 | |
28 | my $obj2 = Child->new; |
29 | ok($obj2->attr, 'has + combines child attribute with parent'); |
30 | |
a02698f1 |
31 | do { |
32 | package Child2; |
33 | use Mouse; |
34 | extends 'Class'; |
35 | |
36 | ::throws_ok { |
37 | has '+nonexistent' => ( |
38 | is => 'rw', |
39 | ); |
40 | } qr/Could not find an attribute by the name of 'nonexistent' to inherit from/; |
41 | }; |
42 | |