Skip to content

Commit 96761b2

Browse files
committed
Add xt test to insure space after comma.
* Only checks non-code. * Has several exceptions for text already in docs/ Closes #666
1 parent c23878a commit 96761b2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

xt/space-after-commma.t

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use v6;
2+
use Test;
3+
use lib 'lib';
4+
5+
=begin overview
6+
7+
Insure any text that isn't a code example has a space after each comma.
8+
9+
=end overview
10+
11+
my @files;
12+
13+
if @*ARGS {
14+
@files = @*ARGS;
15+
} else {
16+
for qx<git ls-files>.lines -> $file {
17+
next unless $file ~~ / '.' ('pod6') $/;
18+
next if $file ~~ / 'contributors.pod6' $/; # names are hard.
19+
push @files, $file;
20+
}
21+
}
22+
23+
plan +@files;
24+
25+
for @files -> $file {
26+
my $ok = True;
27+
28+
my $out;
29+
if $file ~~ / '.pod6' $/ {
30+
my $pod2text = run($*EXECUTABLE-NAME, '--doc', $file, :out);
31+
$out = $pod2text.out;
32+
} else {
33+
$out = $file.IO;
34+
}
35+
36+
for $out.lines -> $line is copy {
37+
next if $line ~~ / ^ ' '/;
38+
39+
# ignore these cases already in docs/ that don't strictly follow rule
40+
$line ~~ s:g/ "','" //;
41+
$line ~~ s:g/ '","' //;
42+
$line ~~ s:g/ << 'a,a,a' >> //;
43+
$line ~~ s:g/ << 'a,a,.' //;
44+
$line ~~ s:g/ << 'a,a' >> //;
45+
$line ~~ s:g/ << 'a,' //;
46+
$line ~~ s:g/ ',a' >> //;
47+
$line ~~ s:g/ '{AM,PM}' //;
48+
$line ~~ s:g/ '(SELF,)' //;
49+
$line ~~ s:g/ '"1,2"' //;
50+
$line ~~ s:g/ '"a,b"' //;
51+
$line ~~ s:g/ '($var,)' //;
52+
$line ~~ s:g/ '(3,)' //;
53+
54+
if $line ~~ / ',' [ <!before ' '> & <!before $> ] / {
55+
$ok = False;
56+
}
57+
}
58+
my $error = $file;
59+
ok $ok, "$error: Must have space after comma.";
60+
}
61+
62+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)