Commit | Line | Data |
46764550 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Test::Fatal; |
5 | |
6 | { |
7 | package MyRole; |
8 | use Moo::Role; |
9 | |
10 | has foo => ( |
11 | is => 'ro', |
12 | required => 1, |
13 | ); |
14 | } |
15 | { |
16 | package MyClass; |
17 | use Moose; |
18 | |
19 | with 'MyRole'; |
20 | |
21 | has '+foo' => ( |
22 | isa => 'Str', |
23 | ); |
24 | } |
25 | |
26 | is( |
27 | exception { MyClass->new(foo => 'bar') }, |
28 | undef, |
29 | 'construct' |
30 | ); |
31 | ok( |
32 | exception { MyClass->new(foo => []) }, |
33 | 'no construct, constraint works' |
34 | ); |
35 | ok( |
36 | exception { MyClass->new() }, |
37 | 'no construct - require still works' |
38 | ); |
39 | |
40 | done_testing; |
41 | |