-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
doc-markup.rakutest
84 lines (77 loc) · 2.02 KB
/
doc-markup.rakutest
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use v6.e.PREVIEW;
use Test;
plan 4;
my $ast;
my $deparsed;
my $raku;
sub ast(RakuAST::Node:D $node --> Nil) {
$ast := $node;
$deparsed := $node.DEPARSE;
$raku := 'use experimental :rakuast; ' ~ $node.raku;
diag $deparsed.chomp;
}
subtest 'simple bold markup' => {
# B<this is bold>
ast RakuAST::Doc::Markup.new(
letter => 'B',
atoms => ("this is bold",)
);
for 'Str', $deparsed, 'Raku', $raku.EVAL.DEPARSE -> $type, $it {
is-deeply $it, 'B<this is bold>', "$type: deparse";
}
}
subtest 'simple bold with italics markup' => {
# B<this I<is> bold>
ast RakuAST::Doc::Markup.new(
letter => 'B',
atoms => (
"this ",
RakuAST::Doc::Markup.new(
letter => "I",
atoms => ("is",)
),
" bold",
)
);
for 'Str', $deparsed, 'Raku', $raku.EVAL.DEPARSE -> $type, $it {
is-deeply $it, 'B<this I<is> bold>', "$type: deparse";
}
}
subtest 'link with code markup' => {
# L<The C<Raku> Programming Language|https://raku.org>
ast RakuAST::Doc::Markup.new(
letter => 'L',
atoms => (
"The ",
RakuAST::Doc::Markup.new(
letter => "C",
atoms => ("Raku",)
),
" Programming Language",
),
meta => ("https://raku.org",)
);
for 'Str', $deparsed, 'Raku', $raku.EVAL.DEPARSE -> $type, $it {
is-deeply $it,
'L<The C<Raku> Programming Language|https://raku.org>',
"$type: deparse";
}
}
subtest 'index entry with multiple lemmas' => {
# X<hash|hashes, definition of;associative arrays>
ast RakuAST::Doc::Markup.new(
letter => 'X',
atoms => ("hash",),
meta => (
"hashes, definition of",
"associative arrays",
),
separator => ';',
);
for 'Str', $deparsed, 'Raku', $raku.EVAL.DEPARSE -> $type, $it {
is-deeply $it,
'X<hash|hashes, definition of;associative arrays>',
"$type: deparse";
}
}
# vim: expandtab shiftwidth=4