testing for methods_provided_by
[gitmo/Role-Tiny.git] / t / concrete-methods.t
CommitLineData
f1ce2b19 1use strict;
2use warnings FATAL => 'all';
3use Test::More;
4use Test::Fatal;
5
6{
7 package MyRole1;
8
9 sub before_role {}
10
11 use Role::Tiny;
cde4d060 12 no warnings 'once';
f1ce2b19 13
14 our $GLOBAL1 = 1;
15 sub after_role {}
16}
17
18{
19 package MyClass1;
cde4d060 20 no warnings 'once';
f1ce2b19 21
22 our $GLOBAL1 = 1;
23 sub method {}
24}
25
26my $role_methods = Role::Tiny->_concrete_methods_of('MyRole1');
27is_deeply([sort keys %$role_methods], ['after_role'],
28 'only subs after Role::Tiny import are methods' );
29
eb2145fc 30my @role_method_list = Role::Tiny->methods_provided_by('MyRole1');
31is_deeply(\@role_method_list, ['after_role'],
32 'methods_provided_by gives method list' );
33
f1ce2b19 34my $class_methods = Role::Tiny->_concrete_methods_of('MyClass1');
35is_deeply([sort keys %$class_methods], ['method'],
36 'only subs from non-Role::Tiny packages are methods' );
37
eb2145fc 38like exception { Role::Tiny->methods_provided_by('MyClass1') },
39 qr/is not a Role::Tiny/,
40 'methods_provided_by refuses to work on classes';
41
f1ce2b19 42done_testing;