From eed1918137aa25bc9f0a3b0786e3f5abec38b374 Mon Sep 17 00:00:00 2001 From: JJ Merelo Date: Thu, 31 May 2018 08:50:38 +0200 Subject: [PATCH] Rewrites test to use actual regexes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also adds "zero width" → zero-width. Closes 2041. --- xt/word-variants.t | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/xt/word-variants.t b/xt/word-variants.t index 73c1c7dd8..9d65fe9ad 100755 --- a/xt/word-variants.t +++ b/xt/word-variants.t @@ -13,16 +13,13 @@ 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; @@ -30,14 +27,11 @@ 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;