Skip to content

Commit

Permalink
Add unicode support
Browse files Browse the repository at this point in the history
Class:Inspector had to remove "Test::Spelling" test completely, because
the test was failing due to a contributor whose name had a none a-zA-Z
character. Adding it as a stopword was not working either.

Pod::Spell documentation @ https://metacpan.org/pod/Pod::Spell#ENCODINGS
notes that default parse_from_file does not apply any encoding layer.
To get the encoding, we should replace it with parse_from_filehandle.

After this change, adding a stopword with non a-zA-Z character works
as expected. I also added a test to make sure this works.
  • Loading branch information
kyzn authored and genio committed May 22, 2019
1 parent da1aca7 commit 50cb8fc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Test/Spelling.pm
Expand Up @@ -101,9 +101,10 @@ sub invalid_words_in {

my $document = '';
open my $handle, '>', \$document;
open my $infile, '<:encoding(UTF-8)', $file;

# save digested POD to the string $document
get_pod_parser()->parse_from_file($file, $handle);
get_pod_parser()->parse_from_filehandle($infile, $handle);

my @words = _get_spellcheck_results($document);

Expand Down
8 changes: 8 additions & 0 deletions t/basic.t
@@ -1,6 +1,7 @@
use Test::Tester;
use Test::More;
use Test::Spelling;
use utf8;

BEGIN {
if (!has_working_spellchecker()) {
Expand All @@ -24,5 +25,12 @@ check_test(sub { pod_file_spelling_ok('t/corpus/bad-pod.pm', 'bad pod has no err
diag => "Errors:\n incorectly",
});

add_stopwords("ünıçöđé");

check_test(sub { pod_file_spelling_ok('t/corpus/unicode-pod.pm', 'unicode pod has no errors') }, {
ok => 1,
name => 'unicode pod has no errors',
});

done_testing;

16 changes: 16 additions & 0 deletions t/corpus/unicode-pod.pm
@@ -0,0 +1,16 @@
package Unicode::Pod;
use strict;
use warnings;

sub foo {}

1;

__END__
=head1 NAME
UTF8::Pod - POD with ünıçöđé
=END

0 comments on commit 50cb8fc

Please sign in to comment.