/
x20spell.t
78 lines (75 loc) · 1.31 KB
/
x20spell.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!perl -w
use strict;
use Test::More;
use ExtUtils::Manifest qw(maniread);
use File::Temp;
eval "use Pod::Spell 1.01";
plan skip_all => "Pod::Spell 1.01 required for spellchecking POD" if $@;
my $manifest = maniread();
my @pod = sort grep !/^inc/ && /\.(pm|pl|pod|PL)$/, keys %$manifest;
plan tests => scalar(@pod);
my @stopwords = qw/
Imager
Imager's
IMAGER
GIF
JPEG
PNG
TIFF
BMP
SGI
TGA
RGB
ICO
PNM
bilevel
dpi
Arnar
Hrafnkelsson
API
paletted
guassian
metadata
CPAN
eg
ie
CMYK
HSV
CGI
const
varargs
FreeType
UTF-8
RGBA
postfix
infix
unary
/;
local %Pod::Wordlist::Wordlist = %Pod::Wordlist::Wordlist;
for my $stop (@stopwords) {
$Pod::Wordlist::Wordlist{$stop} = 1;
}
# see for example:
# https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322
$ENV{LANG} = "C";
$ENV{LC_ALL} = "C";
for my $file (@pod) {
my $check_fh = File::Temp->new;
my $check_filename = $check_fh->filename;
open POD, "< $file"
or die "Cannot open $file for spell check: $!\n";
Pod::Spell->new->parse_from_filehandle(\*POD, $check_fh);
close $check_fh;
my @out = `aspell list <$check_filename`;
unless (ok(@out == 0, "spell check $file")) {
chomp @out;
print "# $_\n" for @out;
print "#----\n";
open my $fh, "<", $check_filename;
while (<$fh>) {
chomp;
print "# $_\n";
}
print "#----\n";
}
}