5 use warnings FATAL => 'all';
7 use Capture::Tiny qw(capture);
8 use Encode qw(encode_utf8 decode_utf8);
10 use File::Temp qw(tempfile);
11 use File::Which qw(which);
12 use Module::Build qw();
15 use XML::LibXSLT qw();
16 use YAML::XS qw(Load);
18 binmode Test::More->builder->$_, ':encoding(UTF-8)'
19 for qw(output failure_output todo_output);
21 # Skip means sweep bugs under the rug.
22 # I want this test to be actually run.
23 BAIL_OUT 'aspell is not installed.' unless which 'aspell';
26 eval { $build = Module::Build->current; 1; }
27 or BAIL_OUT 'We are not in a Module::Build session. Run Build.PL first.';
29 my $locale = $build->notes('locale');
33 my $yaml = Load(encode_utf8(<DATA>));
35 # kill scalar's IV NV or else the smart-match later will bomb out
36 $_ eq 'Infinity' ? 'Infinity' : $_
37 } @{ $yaml->{$locale} };
40 my $iter = File::Next::files({
41 file_filter => sub {/\.html \z/msx},
49 my $stylesheet = XML::LibXSLT->new->parse_stylesheet(
50 XML::LibXML->load_xml(string => <<""));
51 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
52 xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0">
53 <xsl:template match="xhtml:*[\@xml:lang!='$locale']"/>
54 <xsl:template match="xhtml:abbr"/>
55 <xsl:template match="xhtml:acronym"/>
56 <xsl:template match="xhtml:code"/> <!-- filter computerese -->
57 <xsl:template match="\@* | node()"> <!-- apply identity function to rest of nodes -->
59 <xsl:apply-templates select="\@* | node()"/>
64 while (defined(my $html_file = $iter->())) {
67 my ($temp_handle, $temp_file) = tempfile;
68 my $transformed = $stylesheet->transform(XML::LibXML->load_xml(location => $html_file, load_ext_dtd => 0,));
69 $stylesheet->output_fh($transformed, $temp_handle);
71 my ($stdout) = capture {
72 system "aspell -H --encoding=UTF-8 -l $locale list < $temp_file";
74 my @misspelt_words = grep {!($_ ~~ @stopwords)} split /\n/, decode_utf8 $stdout;
75 ok !@misspelt_words, "$html_file ($temp_file) spell-check";
76 diag join "\n", sort @misspelt_words if @misspelt_words;
79 done_testing($file_counter);
193 ## things that should be in the dictionary, but are not
199 ## single foreign words
201 ## misspelt on purpose
317 - Metaobjektprotokoll
321 - Objektmetaprogrammierung
325 - Codewiederverwendung
337 # Lese-Evaluierungs-Ausgabe-Schleife
358 ## nicht im Wörterbuch, aber sollte drin stehen
366 - Gemeinschaftsprojekt
377 - Rollenzusammensetzung
378 - Schnellreferenzkarte
383 ## einzelne Fremdwörter
388 ## absichtlich falsch