Skip to content

Commit

Permalink
Adds test for variants of "normalized" workds like filehandle
Browse files Browse the repository at this point in the history
New words should be added to the `%variants` hash when they are
effectively normalized. Closes #2041
  • Loading branch information
JJ committed May 23, 2018
1 parent 2cb0d39 commit a241350
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/Type/X/IO/DoesNotExist.pod6
Expand Up @@ -7,7 +7,7 @@
=for code :skip-test
class X::IO::DoesNotExist does X::IO is Exception { }
Thrown when doing e.g. file test operations on a non existing path.
Thrown when doing file test operations on a non existing path.
A typical error message is
Expand Down
40 changes: 40 additions & 0 deletions xt/word-variants.t
@@ -0,0 +1,40 @@
#!/usr/bin/env perl6

use v6;
use Test;
use lib 'lib';
use Test-Files;

=begin overview
Insure any text that mentions Perl uses a no-break space after it.
=end overview

my @files = Test-Files.documents;

my %variants = %( "file handle" | "file-handle" => "filehandle" );
plan +@files;

for @files.sort -> $file {
my $ok = True;
my $row = 0;
my @bad;
for $file.IO.slurp.lines -> $line {
$row++;
next if $line ~~ / ^ \s+ /;
for %variants.keys -> $rx {
if $line ~~ m:g/ $rx / {
$ok = False;
@bad.push: "«$0» found in line $row. We prefer 「%variants{$rx}";
}
}
}
my $error = $file;
if !$ok {
$error ~= " {@bad.join: ', '})";
}
ok $ok, "$error: Certain words should be normalized." ;
}

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit a241350

Please sign in to comment.