Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test for variants of "normalized" workds like filehandle
New words should be added to the `%variants` hash when they are effectively normalized. Closes #2041
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |