-
Notifications
You must be signed in to change notification settings - Fork 292
/
word-variants.t
executable file
·51 lines (43 loc) · 1.32 KB
/
word-variants.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/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.pods;
my %variants = %(
"file handle" | "file-handle" => "filehandle",
"run-time" => "runtime",
"short-hand" => "shorthand",
"look-ahead" => "lookahead",
"look-behind" => "lookbehind",
"smart-match" => "smartmatch",
"smart-matches" => "smartmatches",
"smart-matching" => "smartmatching",
"smart-matched" => "smartmatched",
"smart-match" => "smartmatch"
);
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 $result = $file;
if !$ok {
$result ~= " {@bad.join: ', '}): Certain words should be normalized. ";
}
ok $ok, "$result" ;
}
# vim: expandtab shiftwidth=4 ft=perl6