Debian Codegraph @

t/20_policy_pod_spelling.t

raw symbols SCIP
1 #!perl
2
3 =for stopwords arglbargl
4
5 =cut
6
7 use 5.010001scip-perl cpan Perl-Critic 1.156 `5.010001`/;
8 use strictscip-perl cpan Perl-Critic 1.156 strict/;
9 use warningsscip-perl cpan Perl-Critic 1.156 warnings/;
10
11 use Perl::Critic::TestUtilsscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/ qw(pcritique);
12 use Readonlyscip-perl cpan Perl-Critic 1.156 Readonly/;
13
14 use Test::Morescip-perl cpan Perl-Critic 1.156 Test/More/;
15
16 Readonly::Scalarscip-perl cpan Perl-Critic 1.156 Readonly/Scalar(). my $NUMBER_OF_TESTS => 5;
17 planscip-perl cpan Perl-Critic 1.156 main/plan().( tests => $NUMBER_OF_TESTS );
18
19 our $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. = '1.156';
20
21 Perl::Critic::TestUtils::assert_versionscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/assert_version().( $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. );
22 Perl::Critic::TestUtils::block_perlcriticrcscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/block_perlcriticrc().();
23
24 my $code;
25 my $policy = 'Documentation::PodSpelling';
26 my $can_podspell = can_determine_spell_commandscip-perl cpan Perl-Critic 1.156 main/can_determine_spell_command().() && can_run_spell_commandscip-perl cpan Perl-Critic 1.156 main/can_run_spell_command().();
27
28 sub can_determine_spell_commandscip-perl cpan Perl-Critic 1.156 main/can_determine_spell_command(). {
29 my $pol = Perl::Critic::Policy::Documentation::PodSpelling->newscip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/new().();
30 $pol->initialize_if_enabledscip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/initialize_if_enabled().();
31
32 return $pol->_get_spell_command_linescip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/_get_spell_command_line().();
33 }
34
35 sub can_run_spell_commandscip-perl cpan Perl-Critic 1.156 main/can_run_spell_command(). {
36 my $pol = Perl::Critic::Policy::Documentation::PodSpelling->newscip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/new().();
37 $pol->initialize_if_enabledscip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/initialize_if_enabled().();
38
39 return $pol->_run_spell_commandscip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/_run_spell_command().( <<'END_TEST_CODE' );
40 =pod
41
42 =head1 Test The Spell Command
43
44 =cut
45 END_TEST_CODE
46 }
47
48 sub can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell(). {
49 return $can_podspell && ! Perl::Critic::Policy::Documentation::PodSpelling->got_sigpipescip-perl cpan Perl-Critic 1.156 Perl/Critic/Policy/Documentation/PodSpelling/got_sigpipe().();
50 }
51
52 #-----------------------------------------------------------------------------
53 SKIP: {
54
55 $code = <<'END_PERL';
56 =head1 Silly
57
58 =cut
59 END_PERL
60
61 # Sorry about the double negative. The idea is that if aspell fails (say,
62 # because it can not find the right dictionary) or pcritique returns a
63 # non-zero number we want to skip. We have to negate the eval to catch the
64 # aspell failure, and then negate pcritique because we negated the eval.
65 # Clearer code welcome.
66 if ( ! eval { ! pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code) } ) {
67 skipscip-perl cpan Perl-Critic 1.156 main/skip(). 'Test environment is not English', $NUMBER_OF_TESTS;
68 }
69
70 #-----------------------------------------------------------------------------
71
72 $code = <<'END_PERL';
73 =head1 arglbargl
74
75 =cut
76 END_PERL
77
78 isscip-perl cpan Perl-Critic 1.156 main/is().(
79 eval { pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code) },
80 can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell().() ? 1 : undef,
81 'Mispelled header',
82 );
83
84 #-----------------------------------------------------------------------------
85
86 $code = <<'END_PERL';
87 =head1 Test
88
89 arglbargl
90
91 =cut
92 END_PERL
93
94 isscip-perl cpan Perl-Critic 1.156 main/is().(
95 eval { pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code) },
96 can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell().() ? 1 : undef,
97 'Mispelled body',
98 );
99
100 #-----------------------------------------------------------------------------
101
102
103 $code = <<'END_PERL';
104 =for stopwords arglbargl
105
106 =head1 Test
107
108 arglbargl
109
110 =cut
111 END_PERL
112
113 isscip-perl cpan Perl-Critic 1.156 main/is().(
114 eval { pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code) },
115 can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell().() ? 0 : undef,
116 'local stopwords',
117 );
118
119 #-----------------------------------------------------------------------------
120
121 $code = <<'END_PERL';
122 =head1 Test
123
124 arglbargl
125
126 =cut
127 END_PERL
128
129 {
130 my %config = (stop_words => 'foo arglbargl bar');
131 isscip-perl cpan Perl-Critic 1.156 main/is().(
132 eval { pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config) },
133 can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell().() ? 0 : undef ,
134 'global stopwords',
135 );
136 }
137
138 {
139 my %config = (stop_words_file => 't/20_policy_pod_spelling.d/stop-words.txt');
140 isscip-perl cpan Perl-Critic 1.156 main/is().(
141 eval { pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config) },
142 can_podspellscip-perl cpan Perl-Critic 1.156 main/can_podspell().() ? 0 : undef ,
143 'global stopwords from file',
144 );
145 }
146
147 } # end skip
148
149 # Local Variables:
150 # mode: cperl
151 # cperl-indent-level: 4
152 # fill-column: 78
153 # indent-tabs-mode: nil
154 # c-indentation-style: bsd
155 # End:
156 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :