Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 240 lines (185 sloc) 6.851 kb
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
1 use v6;
2
3 # Test various forms of comments
4
5 use Test;
74ad6f7 @lizmat Added plan, removed "done" where appropriate
lizmat authored
6 plan 51;
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
7
cfb4a0d @moritz fix a few smartlinks
moritz authored
8 # L<S02/"Embedded Comments"/"Embedded comments"
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
9 # "#" plus any bracket>
10 {
11
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
12 ok #`[
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
13 Multiline
14 comments
15 is fine
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
16 ] 1, 'multiline embedded comment with #`[]';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
17
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
18 ok #`(
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
19 Parens works also
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
20 ) 1, 'multiline embedded comment with #`()';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
21
7b08120 @perlpilot Add reference to RT #115762
perlpilot authored
22 # RT #115762
e816632 @lizmat s/eval_lives_ok/eval-lives-ok/g
lizmat authored
23 eval-lives-ok "#`( foo )", "comment as first and only statement";
3d2fe5b @perlpilot Simple test for #`() comment at start of statementlist
perlpilot authored
24
e816632 @lizmat s/eval_lives_ok/eval-lives-ok/g
lizmat authored
25 eval-lives-ok "2 * 3\n #`<<<\n comment>>>", "multiline comment with <<<";
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
26
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
27 my $var = #`{ foo bar } 32;
28 is $var, 32, 'embedded comment with #`{}';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
29
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
30 $var = 3 + #`「 this is a comment 」 56;
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
31 is $var, 59, 'embedded comment with LEFT/RIGHT CORNER BRACKET';
32
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
33 is 2 #`『 blah blah blah 』 * 3, 6, 'embedded comment with LEFT/RIGHT WHITE CORNER BRACKET';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
34
35 my @list = 'a'..'c';
36
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
37 is @list[ #`(注释)2 ], 'c', 'embedded comment with FULLWIDTH LEFT/RIGHT PARENTHESIS';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
38
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
39 is @list[ 0 #`《注释》], 'a', 'embedded comment with LEFT/RIGHT DOUBLE ANGLE BRACKET';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
40
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
41 is @list[#`〈注释〉1], 'b', 'embedded comment with LEFT/RIGHT ANGLE BRACKET';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
42
43 # Note that 'LEFT/RIGHT SINGLE QUOTATION MARK' (i.e. ‘’) and
44 # LEFT/RIGHT DOUBLE QUOTATION MARK (i.e. “”) are not valid delimiter
45 # characters.
46
47 #test some 13 more lucky unicode bracketing pairs
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
48 is(1 #`᚛ pa ᚜ +1, 2, 'embedded comment with #`᚛᚜');
49 is(1 #`⁅ re ⁆ +2, 3, 'embedded comment with #`⁅⁆');
50 is(2 #`⁽ ci ⁾ +3, 5, 'embedded comment with #`⁽⁾');
51 is(3 #`❨ vo ❩ +5, 8, 'embedded comment with #`❨ vo ❩');
52 is(5 #`❮ mu ❯ +8, 13, 'embedded comment with #`❮❯');
53 is(8 #`❰ xa ❱ +13, 21, 'embedded comment with #`❰❱');
54 is(13 #`❲ ze ❳ +21, 34, 'embedded comment with #`❲❳');
55 is(21 #`⟦ bi ⟧ +34, 55, 'embedded comment with #`⟦⟧');
56 is(34 #`⦅ so ⦆ +55, 89, 'embedded comment with #`⦅⦆');
57 is(55 #`⦓ pano ⦔ +89, 144, 'embedded comment with #⦓`⦔');
58 is(144 #`⦕ papa ⦖ +233, 377, 'embedded comment with #`⦕⦖');
59 is(377 #`『 pare 』 +610, 987, 'embedded comment with #`『』');
60 is(610 #`﴾ paci ﴿ +987, 1597, 'embedded comment with #`﴾﴿');
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
61 }
62
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
63 # L<S02/"Embedded Comments"/"no space" between "#" and bracket>
6a6cd4f @coke niecza fudging
coke authored
64 #?niecza skip 'Opening bracket is required for #` comment'
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
65 {
66
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
67 throws-like { EVAL "3 * #` (invalid comment) 2" },
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
68 X::Comp::AdHoc, # no exception type yet
69 "no space allowed between '#`' and '('";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
70 throws-like { EVAL "3 * #`\t[invalid comment] 2" },
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
71 X::Comp::AdHoc, # no exception type yet
72 "no tab allowed between '#`' and '['";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
73 throws-like { EVAL "3 * #` \{invalid comment\} 2" },
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
74 X::Comp::AdHoc, # no exception type yet
75 "no spaces allowed between '#`' and '\{'";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
76 throws-like { EVAL "3 * #`\n<invalid comment> 2" },
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
77 X::Syntax::Confused,
78 "no spaces allowed between '#`' and '<'";
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
79
80 }
81
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
82 # L<S02/"User-selected Brackets"/"closed by" "same number of"
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
83 # "closing brackets">
84 {
85
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
86 ok #`<<<
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
87 Or this <also> works...
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
88 >>> 1, '#`<<<...>>>';
2db35ca @moritz rakudo fudges
moritz authored
89 }
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
90
8a6c445 @Mouq Unfudge test that passes on all rakudo backends
Mouq authored
91 # RT #121305
2db35ca @moritz rakudo fudges
moritz authored
92 {
e816632 @lizmat s/eval_lives_ok/eval-lives-ok/g
lizmat authored
93 eval-lives-ok( q{{
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
94 my $var = \#`((( comment ))) 12;
95 is $var, 12, '#`(((...)))';
96 }}, 'Unspaced bracketed comment throws no error' );
2db35ca @moritz rakudo fudges
moritz authored
97 }
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
98
2db35ca @moritz rakudo fudges
moritz authored
99 {
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
100 is(5 * #`<< < >> 5, 25, '#`<< < >>');
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
101
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
102 is(6 * #`<< > >> 6, 36, '#`<< > >>');
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
103 }
104
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
105 # L<S02/"Embedded Comments"/"Brackets may be nested">
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
106 {
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
107 is 3, #`(
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
108 (Nested parens) works also
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
109 ) 3, 'nested parens #`(...(...)...)';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
110
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
111 is 3, #`{
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
112 {Nested braces} works also {}
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
113 } 3, 'nested braces #`{...{...}...}';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
114 }
115
116 # I am not sure if this is speced somewhere:
117 # comments can be nested
1dae23b @TimToady comments do NOT nest, but brackets do
TimToady authored
118 # NB: Not really--brackets can be nested, but the outer comment has No Clue whether the
119 # inner brackets belong to comments or not; it's just counting them regardless of their position.
6a6cd4f @coke niecza fudging
coke authored
120 #?niecza skip 'Possible runaway string'
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
121 {
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
122 is 3, #`(
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
123 comment
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
124 #`{
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
125 internal comment
126 }
127 more comment
128 ) 3, 'comments can be nested with different brackets';
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
129 is 3, #`(
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
130 comment
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
131 #`(
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
132 internal comment
133 )
134 more
135 ) 3, 'comments can be nested with same brackets';
136
137 # TODO:
0bb81f8 @FROGGS eval => EVAL in S02, take 1
FROGGS authored
138 # ok EVAL(" #`{ comment }") fails with an error as it tries to execute
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
139 # comment() before seeing that I meant #`{ comment within this string.
1dae23b @TimToady comments do NOT nest, but brackets do
TimToady authored
140 # NB: This is as it should be. The inside is not parsed till EVAL time.
141 # Interpolation happens before that. --law
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
142
0cbc065 @lizmat s/eval_dies_ok/eval-dies-ok/g
lizmat authored
143 eval-dies-ok " #`<<\n comment\n # >>\n >> 3",
1dae23b @TimToady comments do NOT nest, but brackets do
TimToady authored
144 'single line comment in multiline does not hide delims';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
145 }
146
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
147 # L<S02/"User-selected Brackets"/"Counting of nested brackets"
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
148 # "applies only to" "pairs of brackets of the same length">
149 {
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
150 is -1 #`<<<
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
151 Even <this> <<< also >>> works...
152 >>>, -1, 'nested brackets in embedded comment';
153
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
154 is 'cat', #`{{
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
155 This comment contains unmatched } and { { { { (ignored)
156 Plus a nested {{ ... }} pair (counted)
157 }} 'cat', 'embedded comments with nested/unmatched bracket chars';
158 }
159
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
160 # L<S02/Comments in Unspaces and vice versa/"comment may not contain an unspace">
6a6cd4f @coke niecza fudging
coke authored
161 #?niecza skip 'Excess arguments to CORE eval'
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
162 {
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
163 throws-like { EVAL '$a = #`\ (comment) 32' },
8120b6b @lizmat Last batch of dies_ok -> throws_like cleanup
lizmat authored
164 X::Undeclared,
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
165 "comments can't contain unspace";
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
166 }
167
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
168 # L<S02/Single-line Comments/"# may not be used as"
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
169 # delimiter quoting>
990a9c4 [t/spec] comments.t missing opening {
lwall authored
170 {
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
171 my $a;
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
172 lives-ok { EVAL '$a = q{ 32 }' }, 'sanity check';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
173 is $a, ' 32 ', 'sanity check';
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
174 }
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
175
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
176 {
177 my $a = Nil;
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
178 throws-like { EVAL '$a = q# 32 #;' }, X::Comp::AdHoc, 'misuse of # as quote delimiters';
1dae23b @TimToady comments do NOT nest, but brackets do
TimToady authored
179 ok !$a.defined, "The # character can't be used as quote delimiters";
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
180 }
181
cfb4a0d @moritz fix a few smartlinks
moritz authored
182 # L<S02/Single-line Comments/"single-line comments">
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
183 #?niecza todo
0bb14cf test against http://rt.perl.org/rt3/Ticket/Display.html?id=70752 bug
bbkr authored
184 {
81ce684 @coke standardize on RT #, not URL
coke authored
185 # RT #70752
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
186 lives-ok { EVAL "#=======\n#=======\nuse v6;" },
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
187 "pragma use after single line comments";
0bb14cf test against http://rt.perl.org/rt3/Ticket/Display.html?id=70752 bug
bbkr authored
188 }
189
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by va…
diakopter authored
190 # L<S02/Multiline Comments/POD sections may be>
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
191 lives-ok { EVAL q{{
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
192
0bb81f8 @FROGGS eval => EVAL in S02, take 1
FROGGS authored
193 my $outerVal = EVAL(
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
194 q{my $var = 1;
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
195
196 =begin comment
197
198 This is a comment without
199 a "=cut".
200
201 =end comment
202
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
203 "bar";}
204 );
205 is $outerVal, "bar", '=begin comment without =cut parses to whitespace in code';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
206
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
207 }} }, '=begin comment without =cut eval throws no error';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
208
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
209
210 # L<S02/Multiline Comments/"single paragraph comments">
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
211 lives-ok { EVAL q{{
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
212
0bb81f8 @FROGGS eval => EVAL in S02, take 1
FROGGS authored
213 my $outerVal = EVAL(
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
214 q{10 +
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
215
7127a14 @tadzik Fix Pod in S02-lexical-conventions/comments.t
tadzik authored
216 =comment TimToady is here!
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
217
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
218 1;}
219 );
220 is $outerVal, 11, 'Single paragraph Pod parses to whitespace in code';
221
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
222 }} }, 'Single paragraph Pod eval throws no error';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
223
f5b1f2e @colomon Fudge for niecza.
colomon authored
224 #?niecza todo
9f47446 @lizmat s/lives_ok/lives-ok/g
lizmat authored
225 lives-ok { EVAL q{{
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
226
0bb81f8 @FROGGS eval => EVAL in S02, take 1
FROGGS authored
227 my $outerVal = EVAL(
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
228 q{20 +
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
229
7127a14 @tadzik Fix Pod in S02-lexical-conventions/comments.t
tadzik authored
230 =comment TimToady and audreyt
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
231 are both here, yay!
232
f3c9e75 Bulletproof comment tests against parse failures
Jason Cole authored
233 2;}
234 );
235 is $outerVal, 22, 'Single paragraph Pod, multiple lines parses to whitespace in code';
ea32b9f moved syntax/comments.t to spec/S02-whitespace_and_comments/comments.…
stephenpollei authored
236
e657f36 @lizmat Another batch of (eval_|)dies_ok -> throws_like
lizmat authored
237 }} }, 'Single paragraph Pod, multiple lines eval throws no error';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
238
239 # vim: ft=perl6
Something went wrong with that request. Please try again.