use Test::Requires in tests
[gitmo/Moose.git] / xt / author / pod_coverage.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use Test::Requires {
9     'Test::Pod::Coverage' => '1.04', # skip all if not installed
10 };
11
12 # This is a stripped down version of all_pod_coverage_ok which lets us
13 # vary the trustme parameter per module.
14 my @modules = all_modules();
15 plan tests => scalar @modules;
16
17 my %trustme = (
18     'Moose::Meta::Attribute' => [
19         qw( interpolate_class
20             throw_error
21             attach_to_class
22             )
23     ],
24     'Moose::Meta::Attribute::Native::MethodProvider::Array'   => ['.+'],
25     'Moose::Meta::Attribute::Native::MethodProvider::Bool'    => ['.+'],
26     'Moose::Meta::Attribute::Native::MethodProvider::Code'    => ['.+'],
27     'Moose::Meta::Attribute::Native::MethodProvider::Counter' => ['.+'],
28     'Moose::Meta::Attribute::Native::MethodProvider::Hash'    => ['.+'],
29     'Moose::Meta::Attribute::Native::MethodProvider::String'  => ['.+'],
30     'Moose::Meta::Class'                                      => [
31         qw( check_metaclass_compatibility
32             construct_instance
33             create_error
34             raise_error
35             reinitialize
36             superclasses
37             )
38     ],
39     'Moose::Meta::Class::Immutable::Trait' => ['.+'],
40     'Moose::Meta::Method'                  => ['throw_error'],
41     'Moose::Meta::Method::Accessor'        => [
42         qw( generate_accessor_method
43             generate_accessor_method_inline
44             generate_clearer_method
45             generate_predicate_method
46             generate_reader_method
47             generate_reader_method_inline
48             generate_writer_method
49             generate_writer_method_inline
50             )
51     ],
52     'Moose::Meta::Method::Constructor' => [
53         qw( attributes
54             initialize_body
55             meta_instance
56             new
57             options
58             )
59     ],
60     'Moose::Meta::Method::Destructor' => [ 'initialize_body', 'options' ],
61     'Moose::Meta::Role'               => [
62         qw( alias_method
63             get_method_modifier_list
64             reinitialize
65             reset_package_cache_flag
66             update_package_cache_flag
67             wrap_method_body
68             )
69     ],
70     'Moose::Meta::Mixin::AttributeCore' => ['.+'],
71     'Moose::Meta::Role::Composite' =>
72         [ 'get_method', 'get_method_list', 'has_method', 'add_method' ],
73     'Moose::Role' => [
74         qw( after
75             around
76             augment
77             before
78             extends
79             has
80             inner
81             override
82             super
83             with )
84     ],
85     'Moose::Meta::TypeCoercion'        => ['compile_type_coercion'],
86     'Moose::Meta::TypeCoercion::Union' => ['compile_type_coercion'],
87     'Moose::Meta::TypeConstraint'      => ['compile_type_constraint'],
88     'Moose::Meta::TypeConstraint::Class' =>
89         [qw( equals is_a_type_of is_a_subtype_of )],
90     'Moose::Meta::TypeConstraint::Enum' => [qw( constraint equals )],
91     'Moose::Meta::TypeConstraint::DuckType' =>
92         [qw( constraint equals get_message )],
93     'Moose::Meta::TypeConstraint::Parameterizable' => ['.+'],
94     'Moose::Meta::TypeConstraint::Parameterized'   => ['.+'],
95     'Moose::Meta::TypeConstraint::Role'  => [qw( equals is_a_type_of )],
96     'Moose::Meta::TypeConstraint::Union' => ['compile_type_constraint'],
97     'Moose::Util'                        => ['add_method_modifier'],
98     'Moose::Util::MetaRole'              => ['apply_metaclass_roles'],
99     'Moose::Util::TypeConstraints' => ['find_or_create_type_constraint'],
100 );
101
102 for my $module ( sort @modules ) {
103     my $trustme = [];
104     if ( $trustme{$module} ) {
105         my $methods = join '|', @{ $trustme{$module} };
106         $trustme = [qr/^(?:$methods)$/];
107     }
108
109     pod_coverage_ok(
110         $module, { trustme => $trustme },
111         "Pod coverage for $module"
112     );
113 }