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 ::isnt( ::exception { with('Foo::Role') }, undef, '... no foo method implemented by Foo::Class' );
33 # class which does implement required method
39 ::isnt( ::exception { with('Foo::Class') }, undef, '... cannot consume a class, it must be a role' );
40 ::is( ::exception { with('Foo::Role') }, undef, '... has a foo method implemented by Bar::Class' );
42 sub foo {'Bar::Class::foo'}
45 # role which does implement required method
51 ::is( ::exception { with('Foo::Role') }, undef, '... has a foo method implemented by Bar::Role' );
53 sub foo {'Bar::Role::foo'}
57 [ sort Bar::Role->meta->get_required_method_list ],
59 '... the Bar::Role has not inherited the required method from Foo::Role'
62 # role which does not implement required method
68 ::is( ::exception { with('Foo::Role') }, undef, '... no foo method implemented by Baz::Role' );
72 [ sort Baz::Role->meta->get_required_method_list ],
74 '... the Baz::Role has inherited the required method from Foo::Role'
77 # classes which does not implement required method
83 ::isnt( ::exception { with('Baz::Role') }, undef, '... no foo method implemented by Baz::Class2' );
86 # class which does implement required method
92 ::is( ::exception { with('Baz::Role') }, undef, '... has a foo method implemented by Baz::Class2' );
94 sub foo {'Baz::Class2::foo'}
102 requires qw( meth1 meth2 meth3 meth4 );
111 ::like( ::exception { with('Quux::Role') }, qr/\Q'Quux::Role' requires the methods 'meth1', 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class'/, 'exception mentions all the missing required methods at once' );
115 package Quux::Class2;
120 ::like( ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth2', 'meth3', and 'meth4' to be implemented by 'Quux::Class2'/, 'exception mentions all the missing required methods at once, but not the one that exists' );
124 package Quux::Class3;
127 has 'meth1' => ( is => 'ro' );
128 has 'meth2' => ( is => 'ro' );
130 ::like( ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class3'/, 'exception mentions all the missing methods at once, but not the accessors' );
134 package Quux::Class4;
138 has 'meth2' => ( is => 'ro' );
140 ::like( ::exception { with('Quux::Role') }, qr/'Quux::Role' requires the methods 'meth3' and 'meth4' to be implemented by 'Quux::Class4'/, 'exception mentions all the require methods that are accessors at once, as well as missing methods, but not the one that exists' );