Leolo's guassian2 patch
[imager.git] / xt / x20spell.t
CommitLineData
8294bf44
TC
1#!perl -w
2use strict;
3use Test::More;
4use ExtUtils::Manifest qw(maniread);
5use File::Temp;
2e3f6334
TC
6eval "use Pod::Spell 1.15";
7plan skip_all => "Pod::Spell 1.15 required for spellchecking POD" if $@;
8my @pod = @ARGV;
9unless (@pod) {
10 my $manifest = maniread();
11 @pod = sort grep !/^inc/ && /\.(pm|pl|pod|PL)$/, keys %$manifest;
12}
8294bf44 13plan tests => scalar(@pod);
2e3f6334 14my $my_stopwords = <<'WORDS';
2c331f9f 15API
94995883
TC
16Addi
17Addi's
2c331f9f
TC
18Arnar
19BMP
20Blit
21CGI
22CMYK
23CPAN
75e155e1 24EXIF
2c331f9f 25FreeType
ec5d8b5c 26GDI
2c331f9f
TC
27GIF
28HSV
29Hrafnkelsson
30ICO
31IMAGER
8294bf44
TC
32Imager
33Imager's
8294bf44
TC
34JPEG
35PNG
2c331f9f 36PNM
94995883 37POSIX
2c331f9f
TC
38RGB
39RGBA
8294bf44
TC
40SGI
41TGA
2c331f9f
TC
42TIFF
43UTF-8
44Uncategorized
94995883
TC
45affine
46allocator
8294bf44 47bilevel
94995883 48chromaticities
2c331f9f 49const
94995883 50convolve
8294bf44 51dpi
8294bf44 52eg
94995883 53equalities
67d441b2 54gaussian
35db02fc 55grayscale
8294bf44 56ie
8294bf44 57infix
c18dd26e 58invocant
2c331f9f 59metadata
abffffed 60multi-threaded
24c9233d 61mutex
2c331f9f 62paletted
94995883 63parsers
2c331f9f
TC
64postfix
65preload
66preloading
67preloads
94995883
TC
68quantization
69quantize
70quantized
71radians
130225b1 72renderer
94995883
TC
73resizing
74sRGB
75specular
76stereoscopy
d2549cc4 77tuple
2c331f9f 78unary
94995883 79unassociated
9d5ff8a6 80unseekable
94995883 81untransformed
2c331f9f 82varargs
2e3f6334 83WORDS
8294bf44
TC
84
85# see for example:
86# https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322
87$ENV{LANG} = "C";
88$ENV{LC_ALL} = "C";
89for my $file (@pod) {
90 my $check_fh = File::Temp->new;
91 my $check_filename = $check_fh->filename;
2e3f6334
TC
92 my $work_fh = File::Temp->new;
93 my $work_filename = $work_fh->filename;
94 open my $pod, "<", $file
8294bf44 95 or die "Cannot open $file for spell check: $!\n";
2e3f6334
TC
96 my @local_stop;
97 my $stop_re = qr/\b(xxxxx)\b/;
98 while (<$pod>) {
99 if (/^=for\s+stopwords\s+(.*)/) {
100 push @local_stop, map quotemeta, split ' ', $1;
101 my $stop_re_str = join('|', @local_stop);
102 $stop_re = qr/\b($stop_re_str)\b/;
103 }
104 else {
105 s/$stop_re/ /g;
106 }
107 print $work_fh $_;
108 }
109 seek $work_fh, 0, SEEK_SET;
110 my $spell = Pod::Spell->new;
111 $spell->stopwords->learn_stopwords($my_stopwords);
112 $spell->parse_from_filehandle($work_fh, $check_fh);
113 close $work_fh;
8294bf44
TC
114 close $check_fh;
115
116 my @out = `aspell list <$check_filename`;
117 unless (ok(@out == 0, "spell check $file")) {
118 chomp @out;
125e8835 119 diag $_ for @out;
8294bf44
TC
120 print "#----\n";
121 open my $fh, "<", $check_filename;
122 while (<$fh>) {
123 chomp;
124 print "# $_\n";
125 }
126 print "#----\n";
127 }
128}