6 use Test::More tests => 14;
20 [ sort Foo::Role->meta->get_required_method_list ],
22 '... the Foo::Role has a required method (foo)'
25 # classes which does not implement required method
31 ::dies_ok { with('Foo::Role') }
32 '... no foo method implemented by Foo::Class';
35 # class which does implement required method
41 ::dies_ok { with('Foo::Class') }
42 '... cannot consume a class, it must be a role';
43 ::lives_ok { with('Foo::Role') }
44 '... has a foo method implemented by Bar::Class';
46 sub foo {'Bar::Class::foo'}
49 # role which does implement required method
55 ::lives_ok { with('Foo::Role') }
56 '... has a foo method implemented by Bar::Role';
58 sub foo {'Bar::Role::foo'}
62 [ sort Bar::Role->meta->get_required_method_list ],
64 '... the Bar::Role has not inherited the required method from Foo::Role'
67 # role which does not implement required method
73 ::lives_ok { with('Foo::Role') }
74 '... no foo method implemented by Baz::Role';
78 [ sort Baz::Role->meta->get_required_method_list ],
80 '... the Baz::Role has inherited the required method from Foo::Role'
83 # classes which does not implement required method
89 ::dies_ok { with('Baz::Role') }
90 '... no foo method implemented by Baz::Class2';
93 # class which does implement required method
99 ::lives_ok { with('Baz::Role') }
100 '... has a foo method implemented by Baz::Class2';
102 sub foo {'Baz::Class2::foo'}
110 requires qw( meth1 meth2 meth3 meth4 );
119 ::throws_ok { with('Quux::Role') }
120 qr/\Q'Quux::Role' requires the methods 'meth1', 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class'/,
121 'exception mentions all the missing required methods at once';
125 package Quux::Class2;
130 ::throws_ok { with('Quux::Role') }
131 qr/'Quux::Role' requires the methods 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class2'/,
132 'exception mentions all the missing required methods at once, but not the one that exists';
136 package Quux::Class3;
139 has 'meth1' => ( is => 'ro' );
140 has 'meth2' => ( is => 'ro' );
142 ::throws_ok { with('Quux::Role') }
143 qr/\Q'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class3'\E\n
144 \Q'Quux::Role' requires the methods 'meth1' and 'meth2' to be implemented by 'Quux::Class3' but the method is only an attribute accessor/x,
145 'exception mentions all the require methods that are accessors at once, as well as missing methods';
149 package Quux::Class4;
153 has 'meth2' => ( is => 'ro' );
155 ::throws_ok { with('Quux::Role') }
156 qr/\Q'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class4'\E\n
157 \Q'Quux::Role' requires the method 'meth2' to be implemented by 'Quux::Class4' but the method is only an attribute accessor/x,
158 'exception mentions all the require methods that are accessors at once, as well as missing methods, but not the one that exists';