Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / t / 20_policy_podspelling.t
1 #!perl
2
3 ##############################################################################
4 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/20_policy_podspelling.t $
5 #     $Date: 2008-06-21 19:57:54 -0700 (Sat, 21 Jun 2008) $
6 #   $Author: clonezone $
7 # $Revision: 2464 $
8 ##############################################################################
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Test::More tests => 4;
14
15 # common P::C testing tools
16 use Perl::Critic::TestUtils qw(pcritique);
17 Perl::Critic::TestUtils::block_perlcriticrc();
18
19 my $code;
20 my $policy = 'Documentation::PodSpelling';
21 my %config;
22 my $can_podspell =
23         eval {require Pod::Spell}
24     &&  can_determine_spell_command()
25     &&  can_run_spell_command();
26
27 sub can_determine_spell_command {
28     my $policy = Perl::Critic::Policy::Documentation::PodSpelling->new();
29     $policy->initialize_if_enabled();
30
31     return $policy->_get_spell_command_line();
32 }
33
34 sub can_run_spell_command {
35     my $policy = Perl::Critic::Policy::Documentation::PodSpelling->new();
36     $policy->initialize_if_enabled();
37
38     return $policy->_run_spell_command( <<'END_TEST_CODE' );
39 =pod
40
41 =head1 Test The Spell Command
42
43 =cut
44 END_TEST_CODE
45 }
46
47 sub can_podspell {
48     return $can_podspell && ! Perl::Critic::Policy::Documentation::PodSpelling->got_sigpipe();
49 }
50
51 #-----------------------------------------------------------------------------
52 SKIP: {
53
54 $code = <<'END_PERL';
55 =head1 Silly
56
57 =cut
58 END_PERL
59
60 if ( eval { pcritique($policy, \$code, \%config) } ) {
61    skip 'Test environment is not English', 4
62 }
63
64 #-----------------------------------------------------------------------------
65
66 $code = <<'END_PERL';
67 =head1 arglbargl
68
69 =cut
70 END_PERL
71
72 is(
73     eval { pcritique($policy, \$code, \%config) },
74     can_podspell() ? 1 : undef,
75     'Mispelled header',
76 );
77
78 #-----------------------------------------------------------------------------
79
80 $code = <<'END_PERL';
81 =head1 Test
82
83 arglbargl
84
85 =cut
86 END_PERL
87
88 is(
89     eval { pcritique($policy, \$code, \%config) },
90     can_podspell() ? 1 : undef,
91     'Mispelled body',
92 );
93
94 #-----------------------------------------------------------------------------
95
96
97 $code = <<'END_PERL';
98 =for stopwords arglbargl
99
100 =head1 Test
101
102 arglbargl
103
104 =cut
105 END_PERL
106
107 is(
108     eval { pcritique($policy, \$code, \%config) },
109     can_podspell() ? 0 : undef,
110     'local stopwords',
111 );
112
113 #-----------------------------------------------------------------------------
114
115 $code = <<'END_PERL';
116 =head1 Test
117
118 arglbargl
119
120 =cut
121 END_PERL
122
123 {
124     local $config{stop_words} = 'foo arglbargl bar';
125     is(
126         eval { pcritique($policy, \$code, \%config) },
127         can_podspell() ? 0 : undef ,
128         'global stopwords',
129     );
130 }
131
132 } # end skip
133
134 #-----------------------------------------------------------------------------
135
136 # ensure we run true if this test is loaded by
137 # t/20_policy_podspelling.t_without_optional_dependencies.t
138 1;
139
140 # Local Variables:
141 #   mode: cperl
142 #   cperl-indent-level: 4
143 #   fill-column: 78
144 #   indent-tabs-mode: nil
145 #   c-indentation-style: bsd
146 # End:
147 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :