Make coercion work for parameterized types
[gitmo/Mouse.git] / t / 030-has-plus.t
CommitLineData
7e2909e5 1#!/usr/bin/env perl
2use strict;
3use warnings;
a02698f1 4use Test::More tests => 3;
eab81545 5use Test::Exception;
7e2909e5 6
7do {
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
25my $obj = Class->new;
26ok(!$obj->attr, 'has + does not affect the superclass');
27
28my $obj2 = Child->new;
29ok($obj2->attr, 'has + combines child attribute with parent');
30
a02698f1 31do {
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