Skip to content

Commit

Permalink
Rewrites test to use actual regexes
Browse files Browse the repository at this point in the history
Also adds "zero width" → zero-width. Closes 2041.
  • Loading branch information
JJ committed May 31, 2018
1 parent e38a619 commit eed1918
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions xt/word-variants.t
Expand Up @@ -13,31 +13,25 @@ Insure any text that mentions Perl uses a no-break space after it.

my @files = Test-Files.pods;

my %variants = %(
"file handle" | "file-handle" => "filehandle",
"run-time" | "run time" => "runtime",
"short-hand" | "short hand" => "shorthand",
"look-ahead" => "lookahead",
"look-behind" | "look behind" => "lookbehind",
"smart-match" | "smart match" => "smartmatch",
"smart-matches" | "smart matches" => "smartmatches",
"smart-matching" | "smart matching" => "smartmatching",
"smart-matched" | "smart matched" => "smartmatched"
my %variants = %( filehandle => rx/file [\s+|\-] handle/,
runtime => rx/run [\s+|\-] time/,
shorthand => rx/short [\s+|\-] hand/,
lookahead => rx/look \- ahead/,
lookbehind => rx/look [\s+|\-] behind/,
smartmatch => rx/smart [\s+|\-] match/,
zero-width => rx/zero \s+ width/
);
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 $content = $file.IO.slurp.lines.join(" ");
for %variants.kv -> $word, $rx {
if $content ~~ $rx {
$ok = False;
@bad.push: "«$/» found. We prefer 「$word";
}
}
my $result = $file;
Expand Down

0 comments on commit eed1918

Please sign in to comment.