321f139fb5c5c69582b1080c2bd60fa09d20f9ff
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / t / 99_pod_coverage.t
1 #!perl
2
3 ##############################################################################
4 #     $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/99_pod_coverage.t $
5 #    $Date: 2008-06-06 00:48:04 -0500 (Fri, 06 Jun 2008) $
6 #   $Author: clonezone $
7 # $Revision: 2416 $
8 ##############################################################################
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Test::More;
14
15 eval 'use Test::Pod::Coverage 1.04'; ## no critic
16 plan skip_all => 'Test::Pod::Coverage 1.00 requried to test POD' if $@;
17
18 {
19     # HACK: Perl::Critic::Violation uses Pod::Parser to extract the
20     # DIAGNOSTIC section of the POD in each Policy module.  This
21     # happens when the Policy first C<uses> the Violation module.
22     # Meanwhile, Pod::Coverage also uses Pod::Parser to extract the
23     # POD and compare it with the subroutines that are in the symbol
24     # table for that module.  For reasons I cannot yet explain, using
25     # Pod::Parser twice this way causes the symbol table to get very
26     # wacky and this test script dies with "Can't call method 'OPEN'
27     # on IO::String at line 1239 of Pod/Parser.pm".
28
29     # For now, my workaround is to temporarily redefine the import()
30     # method in the Violation module so that it doesn't do any Pod
31     # parsing.  I'll look for a better solution (or file a bug report)
32     # when / if I have better understanding of the problem.
33
34     no warnings;
35     require Perl::Critic::Violation;
36     *Perl::Critic::Violation::import = sub { 1 };
37 }
38
39 my @trusted_methods  = get_trusted_methods();
40 my $method_string = join ' | ', @trusted_methods;
41 my $trusted_rx = qr{ \A (?: $method_string ) \z }x;
42 all_pod_coverage_ok( {trustme => [$trusted_rx]} );
43
44 #-----------------------------------------------------------------------------
45
46 sub get_trusted_methods {
47     return qw(
48         new
49         initialize_if_enabled
50         violates
51         applies_to
52         default_themes
53         default_maximum_violations_per_document
54         default_severity
55         supported_parameters
56         description
57         Fields
58         got_sigpipe
59     );
60 }
61
62 ##############################################################################
63 # Local Variables:
64 #   mode: cperl
65 #   cperl-indent-level: 4
66 #   fill-column: 78
67 #   indent-tabs-mode: nil
68 #   c-indentation-style: bsd
69 # End:
70 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :