Commit | Line | Data |
fff0a09d |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More; |
5 | use Test::Moose; |
6 | use Test::Fatal; |
7 | |
8 | plan skip_all => "only relevant for Moose 2.0" |
9 | if Moose->VERSION < 1.9900; |
10 | |
11 | { |
12 | package Foo::Role; |
13 | use Moose::Role; |
14 | use MooseX::UndefTolerant; |
15 | |
16 | has foo => ( |
17 | is => 'ro', |
18 | isa => 'Str', |
19 | predicate => 'has_foo', |
20 | ); |
21 | } |
22 | |
23 | { |
24 | package Foo; |
25 | use Moose; |
26 | |
27 | with 'Foo::Role'; |
28 | } |
29 | |
30 | { |
31 | package Bar::Role; |
32 | use Moose::Role; |
33 | } |
34 | |
35 | { |
36 | package Bar; |
37 | use Moose; |
38 | |
39 | with 'Foo::Role', 'Bar::Role'; |
40 | } |
41 | |
42 | with_immutable { |
43 | my $foo; |
44 | is(exception { $foo = Foo->new(foo => undef) }, undef, |
45 | "can set to undef in constructor"); |
46 | ok(!$foo->has_foo, "role attribute isn't set"); |
47 | |
48 | my $bar; |
49 | is(exception { $bar = Bar->new(foo => undef) }, undef, |
50 | "can set to undef in constructor"); |
51 | ok(!$bar->has_foo, "role attribute isn't set"); |
52 | } 'Foo', 'Bar'; |
53 | |
54 | done_testing; |