19 [ sort Foo::Role->meta->get_required_method_list ],
21 '... the Foo::Role has a required method (foo)'
24 # classes which does not implement required method
30 ::ok ::exception { with('Foo::Role') },
31 '... no foo method implemented by Foo::Class';
34 # class which does implement required method
40 ::ok ::exception { with('Foo::Class') },
41 '... cannot consume a class, it must be a role';
42 ::ok ! ::exception { with('Foo::Role') },
43 '... has a foo method implemented by Bar::Class';
45 sub foo {'Bar::Class::foo'}
48 # role which does implement required method
54 ::ok ! ::exception { with('Foo::Role') },
55 '... has a foo method implemented by Bar::Role';
57 sub foo {'Bar::Role::foo'}
61 [ sort Bar::Role->meta->get_required_method_list ],
63 '... the Bar::Role has not inherited the required method from Foo::Role'
66 # role which does not implement required method
72 ::ok ! ::exception { with('Foo::Role') },
73 '... no foo method implemented by Baz::Role';
77 [ sort Baz::Role->meta->get_required_method_list ],
79 '... the Baz::Role has inherited the required method from Foo::Role'
82 # classes which does not implement required method
88 ::ok ::exception { with('Baz::Role') },
89 '... no foo method implemented by Baz::Class2';
92 # class which does implement required method
98 ::ok ! ::exception { with('Baz::Role') },
99 '... has a foo method implemented by Baz::Class2';
101 sub foo {'Baz::Class2::foo'}
109 requires qw( meth1 meth2 meth3 meth4 );
118 ::like ::exception { with('Quux::Role') },
119 qr/\Q'Quux::Role' requires the methods 'meth1', 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class'/,
120 'exception mentions all the missing required methods at once';
124 package Quux::Class2;
129 ::like ::exception { with('Quux::Role') },
130 qr/'Quux::Role' requires the methods 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class2'/,
131 'exception mentions all the missing required methods at once, but not the one that exists';
135 package Quux::Class3;
138 has 'meth1' => ( is => 'ro' );
139 has 'meth2' => ( is => 'ro' );
141 ::like ::exception { with('Quux::Role') },
142 qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class3'/,
143 'exception mentions all the missing methods at once, but not the accessors';
147 package Quux::Class4;
151 has 'meth2' => ( is => 'ro' );
153 ::like ::exception { with('Quux::Role') },
154 qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class4'/,
155 'exception mentions all the require methods that are accessors at once, as well as missing methods, but not the one that exists';