Skip to content

Commit f7725e1

Browse files
committed
C<> should not have leading or trailing whitespace
1 parent bbfb1b1 commit f7725e1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

xt/rakudoc-c.rakutest

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env raku
2+
3+
=begin overview
4+
5+
Check any L<> references for validity.
6+
7+
=end overview
8+
9+
use Test;
10+
use lib $*PROGRAM.parent(2).child('lib');
11+
12+
use Test-Files;
13+
use Pod::Convenience;
14+
15+
my @files = Test-Files.pods;
16+
17+
if @files {
18+
plan +@files;
19+
} else {
20+
plan :skip-all<No rakudoc files specified>
21+
}
22+
23+
sub is-valid-c($contents) {
24+
for @$contents -> $string {
25+
is $string, $string.trim, "C<$string> no extra whitespace.";
26+
}
27+
}
28+
29+
sub walk-content($x) {
30+
for $x.contents -> $contents {
31+
next unless $contents;
32+
for @$contents -> $item {
33+
if $item ~~ Pod::FormattingCode and $item.type eq 'C' {
34+
is-valid-c($item.contents);
35+
} elsif $item !~~ Str {
36+
walk-content($item);
37+
}
38+
}
39+
}
40+
}
41+
42+
for @files -> $file {
43+
my @chunks = extract-pod($file).contents;
44+
45+
# This emits pass or flunk for each local L<> found.
46+
subtest $file => {
47+
walk-content($_) for @chunks;
48+
}
49+
}

0 commit comments

Comments
 (0)