- Notifications
You must be signed in to change notification settings - Fork 135
/
Copy path04-code.t
166 lines (123 loc) · 4.04 KB
/
04-code.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
useTest;
plan50;
my$r;
=beginpod
This ordinary paragraph introduces a code block:
$this = 1 * code('block');
$which.is_specified(:by<indenting>);
$which.spans(:newlines);
=endpod
$r=$=pod[0];
is$r.contents[0].contents, 'This ordinary paragraph introduces a code block:';
isa-ok$r.contents[1], Pod::Block::Code;
is$r.contents[1].contents.Str.subst("\r\n", "\n", :g), q[$this = 1 * code('block');
$which.is_specified(:by<indenting>);
$which.spans(:newlines);].subst("\r\n", "\n", :g);
# more fancy code blocks
=beginpod
This is an ordinary paragraph
While this is not
This is a code block
=head1Mumble mumble
Unsurprisingly, this is also a code block
(with fancy indentation too)
But this is just a text. Again
=endpod
$r=$=pod[1];
is$r.contents.elems, 5;
is$r.contents[0].contents, 'This is an ordinary paragraph';
isa-ok$r.contents[1], Pod::Block::Code;
is$r.contents[1].contents, "While this is not\nThis is a code block";
isa-ok$r.contents[2], Pod::Block;
is$r.contents[2].contents[0].contents, 'Mumble mumble';
#?rakudo 2 todo 'legacy pod grammar incorrectly assumes not code'
isa-ok$r.contents[3], Pod::Block::Code;
is$r.contents[3].contents, "Unsurprisingly, this is also a code block\n"
~" (with fancy indentation too)";
is$r.contents[4].contents, "But this is just a text. Again";
=beginpod
Tests for the feed operators
==> and <==
=endpod
$r=$=pod[2];
is$r.contents[0].contents, 'Tests for the feed operators';
isa-ok$r.contents[1], Pod::Block::Code;
is$r.contents[1].contents, "==> and <==";
=beginpod
Fun comes
This is code
Ha, what now?
one more block of code
just to make sure it works
or better: maybe it'll break!
=endpod
$r=$=pod[3];
is$r.contents.elems, 4;
is$r.contents[0].contents, 'Fun comes';
isa-ok$r.contents[1], Pod::Block::Code;
is$r.contents[1].contents, 'This is code';
isa-ok$r.contents[2], Pod::Block::Code;
is$r.contents[2].contents, 'Ha, what now?';
isa-ok$r.contents[3], Pod::Block::Code;
is$r.contents[3].contents, "one more block of code\n"
~"just to make sure it works\n"
~" or better: maybe it'll break!";
=beginpod
=head1A heading
This is Pod too. Specifically, this is a simple C<para> block
$this = pod('also'); # Specifically, a code block
=endpod
$r=$=pod[4];
is$r.contents.elems, 3;
isa-ok$r.contents[0], Pod::Block;
is$r.contents[0].contents[0].contents, 'A heading';
is$r.contents[1].contents[0],
'This is Pod too. Specifically, this is a simple ';
isa-ok$r.contents[1].contents[1], Pod::FormattingCode;
is$r.contents[1].contents[1].type, 'C';
is$r.contents[1].contents[1].contents, 'para';
is$r.contents[1].contents[2], ' block';
isa-ok$r.contents[2], Pod::Block::Code;
is$r.contents[2].contents,
q[$this = pod('also'); # Specifically, a code block];
=beginpod
this is code
=forPodcast
this is not
this is also code
=beginItemization
this is not
=endItemization
=beginQuitem
and this is not
=endQuitem
=beginitem
and this is!
=enditem
=endpod
$r=$=pod[5];
is$r.contents.elems, 6;
isa-ok$r.contents[0], Pod::Block::Code;
is$r.contents[0].contents, 'this is code';
isa-ok$r.contents[1], Pod::Block::Named;
is$r.contents[1].name, 'Podcast';
is$r.contents[1].contents[0].contents, 'this is not';
#?rakudo todo 'legacy pod grammar incorrectly assumes not code'
isa-ok$r.contents[2], Pod::Block::Code;
is$r.contents[2].contents, 'this is also code';
isa-ok$r.contents[3], Pod::Block::Named;
is$r.contents[3].name, 'Itemization';
is$r.contents[3].contents[0].contents, 'this is not';
isa-ok$r.contents[4], Pod::Block::Named;
is$r.contents[4].name, 'Quitem';
is$r.contents[4].contents[0].contents, 'and this is not';
isa-ok$r.contents[5].contents[0], Pod::Block::Code;
is$r.contents[5].contents[0].contents, 'and this is!';
=begincode
foo foo
=begincode
=endcode
=endcode
$r=$=pod[6];
isa-ok$r, Pod::Block::Code;
# vim: expandtab shiftwidth=4