Skip to content

Commit

Permalink
clean up test descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Mar 6, 2023
1 parent bd4d0c3 commit a8963e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/Type/Bool.rakudoc
Expand Up @@ -70,7 +70,7 @@ the "lowest" Bool enum value, its own predecessor is also C<False>.

method enums(--> Hash:D)

Returns a L<Hash|/type/Hash> of enum-pairs. Works on both the C<Bool> type
Returns a L<Hash|/type/Hash> of enum-pairs. Works on both the L<C<Bool>|/type/Bool> type
and any key.

say Bool.enums; # OUTPUT: «{False => 0, True => 1}␤»
Expand Down
26 changes: 21 additions & 5 deletions xt/rakudoc-types.rakutest
Expand Up @@ -26,6 +26,17 @@ if @files {
plan :skip-all<No rakudoc files specified>
}

sub render-node($node) {
my $type = $node.contents.join('');
my $result = $node.type ~ '<' ~ $type;
if $node.type eq 'L' {
$result ~= '|' ~ $node.meta
}
$result ~= '>';

$result;
}

sub is-valid-type($node, $parent) {
# only care about I<>, C<>, L<>, etc.
return unless $node ~~ Pod::FormattingCode;
Expand All @@ -34,25 +45,29 @@ sub is-valid-type($node, $parent) {
my $type = $node.contents.join('').subst('::','/', :g);
return unless "doc/Type/$type.rakudoc".IO.f;

# Might be nested but we only report on the innermost here.
if $node.type ne 'C' {
flunk $node.type ~ '<' ~ $type ~ "> should be L<C<$type>|/type/$type>";
flunk "{render-node($node)} should be L<C<$type>|/type/$type>";
return;
}

# Probably in a paragraph
if $parent === Nil or ! ($parent ~~ Pod::FormattingCode) {
flunk $node.type ~ '<' ~ $type ~ "> should be L<C<$type>|/type/$type> - bad parent class: {$parent.^name}";
flunk "{render-node($node)} should be L<C<$type>|/type/$type>";
return;
}

# Wrapped, but not in an L<>
if $parent.type ne 'L' {
flunk $parent.type ~ '<C<' ~ $type ~ ">> should be L<C<$type>|/type/$type> - bad parent FormattingCode";
flunk "$parent.type<{render-node($node)}> should be L<C<$type>|/type/$type> - bad parent FormattingCode";
return;
} elsif $parent.meta ne "/type/$type" {
flunk 'L<C<' ~ $type ~ '|' ~ $parent.meta~ ">> should be L<C<$type>|/type/$type> - bad link";
# Wrapped in an L<> but wrong URL
flunk "L<{render-node($node)}|$parent.meta> should be L<C<$type>|/type/$type> - bad link";
} else {
# \o/
pass "$type reference correctly formatted.";
}

}

sub walk-content($item, $parent) {
Expand All @@ -64,6 +79,7 @@ sub walk-content($item, $parent) {
}
}

# Walk through pod on each file.
for @files -> $file {
my @chunks = extract-pod($file).contents;

Expand Down

0 comments on commit a8963e1

Please sign in to comment.