remove unneeded shebang
[gitmo/MooseX-UndefTolerant.git] / t / roles.t
CommitLineData
fff0a09d 1use strict;
2use warnings;
26dd75e6 3
fff0a09d 4use Test::More;
5use Test::Moose;
6use Test::Fatal;
7
8plan 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
b4fdbd0a 42{
43 package Baz::Role;
44 use Moose::Role;
45 with 'Foo::Role';
46}
47
48{
49 package Baz;
50 use Moose;
51
52 with 'Baz::Role';
53}
54
55{
56 package Quux;
57 use Moose;
58
59 with 'Foo::Role';
60 with 'Bar::Role';
61}
62
fff0a09d 63with_immutable {
64 my $foo;
65 is(exception { $foo = Foo->new(foo => undef) }, undef,
66 "can set to undef in constructor");
67 ok(!$foo->has_foo, "role attribute isn't set");
68
69 my $bar;
70 is(exception { $bar = Bar->new(foo => undef) }, undef,
71 "can set to undef in constructor");
72 ok(!$bar->has_foo, "role attribute isn't set");
b4fdbd0a 73
74 my $baz;
75 is(exception { $baz = Baz->new(foo => undef) }, undef,
76 "can set to undef in constructor");
77 ok(!$baz->has_foo, "role attribute isn't set");
78
79 my $quux;
80 is(exception { $quux = Quux->new(foo => undef) }, undef,
81 "can set to undef in constructor");
82 ok(!$quux->has_foo, "role attribute isn't set");
83} 'Foo', 'Bar', 'Baz', 'Quux';
fff0a09d 84
85done_testing;