Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 287 lines (239 sloc) 7.53 kb
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
2
db4bde7 [t/spec] add 'use MONKEY_TYPING' where appropriate
lwall authored
3 use MONKEY_TYPING;
4
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
5 use Test;
6
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
7 plan 75;
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
8
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by vario...
diakopter authored
9 # L<S02/"Unspaces"/This is known as the "unspace">
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
10
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
11
12 ok(4\ .sqrt == 2, 'unspace with numbers');
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
13 is(4\#`(quux).sqrt, 2, 'unspace with comments');
64c6ebb [t/spec] Some #?rakudo fudging for unspace.t .
pmichaud authored
14 is("x"\ .chars, 1, 'unspace with strings');
15 is("x"\ .chars(), 1, 'unspace with strings + parens');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
16
734bc95 [t/spec]
moritz authored
17 #?rakudo skip 'unspace with postfix operators'
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
18 {
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
19 my $foo = 4;
734bc95 [t/spec]
moritz authored
20 is($foo.++, 4, '(short) unspace with postfix inc');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
21 is($foo, 5, '(short) unspace with postfix inc really postfix');
734bc95 [t/spec]
moritz authored
22 is($foo\ .++, 5, 'unspace with postfix inc');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
23 is($foo, 6, 'unspace with postfix inc really postfix');
734bc95 [t/spec]
moritz authored
24 is($foo\ .--, 6, 'unspace with postfix dec');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
25 is($foo, 5, 'unspace with postfix dec really postfix');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
26 }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
27
64c6ebb [t/spec] Some #?rakudo fudging for unspace.t .
pmichaud authored
28 is("xxxxxx"\.chars, 6, 'unspace without spaces');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
29 is("xxxxxx"\
64c6ebb [t/spec] Some #?rakudo fudging for unspace.t .
pmichaud authored
30 .chars, 6, 'unspace with newline');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
31
2a6e478 [STD] remove fossil parsing of no-longer-specced :foo.() et al.
lwall authored
32 is((:foo\ ("bar")), ('foo' => "bar"), 'unspace with adverb');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
33
34 is( ~([1,2,3]\ .[2,1,0]), "3 2 1", 'unspace on postfix subscript');
35
001e798 @moritz &eval does not catch exceptions.
moritz authored
36 #?rakudo skip 'unimplemented postfix forms'
37 {
38 my @array = 1,2,3;
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
39
40 @array\ .>>++;
41 @array>>\ .++;
42 @array\ .>>\ .++;
43 @array\ .»++;
44 @array»\ .++;
45 @array\ .»\ .++;
001e798 @moritz &eval does not catch exceptions.
moritz authored
46 is( ~@array, "7 8 9", 'unspace with postfix hyperops');
47 }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
48
49
50 #Test the "unspace" and unspace syntax
51
52
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
53 #This makes 'foo.lc' and 'foo .lc' mean different things
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
54 multi foo() { 'a' }
55 multi foo($x) { $x }
56
57 #This should do the same, but currently doesn't
58 sub bar($x? = 'a') { $x }
59
60 $_ = 'b';
61
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
62 is((foo.lc ), 'a', 'sanity - foo.lc');
63 is((foo .lc ), 'b', 'sanity - foo .lc');
64 is((bar.lc ), 'a', 'sanity - bar.lc');
65 is((bar .lc ), 'b', 'sanity - bar .lc');
66 is((foo\.lc ), 'a', 'short unspace');
67 is((foo\ .lc ), 'a', 'unspace');
f9202ea A couple of todos and skips; we can now run most of what alpha did of un...
jnthn authored
68 #?rakudo skip 'parse fail'
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
69 is((foo \ .lc), 'b', 'not a unspace');
70 eval_dies_ok('fo\ o.lc', 'unspace not allowed in identifier');
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
71 is((foo\ .lc), 'a', 'longer dot');
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
72 is((foo\#`( comment ).lc), 'a', 'unspace with embedded comment');
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
73 eval_dies_ok('foo\#\ ( comment ).lc', 'unspace can\'t hide space between # and opening bracket');
3e0bfa3 [t/spec]: More fudging for unspace.t .
pmichaud authored
74 is((foo\ # comment
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
75 .lc), 'a', 'unspace with end-of-line comment');
3e0bfa3 [t/spec]: More fudging for unspace.t .
pmichaud authored
76 is((:foo\ <bar>), (:foo<bar>), 'unspace in colonpair');
77 #?rakudo skip 'unimplemented'
0956e55 @colomon Fudge for niecza.
colomon authored
78 #?niecza skip 'Unable to resolve method postcircumfix:<( )> in class Str'
3e0bfa3 [t/spec]: More fudging for unspace.t .
pmichaud authored
79 is((foo\ .\ ("x")), 'x', 'unspace is allowed both before and after method .');
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
80 is((foo\
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
81 =begin comment
82 blah blah blah
83 =end comment
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
84 .lc), 'a', 'unspace with pod =begin/=end comment');
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
85 {
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
86 is((foo\
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
87 =for comment
88 blah
89 blah
90 blah
91
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
92 .lc), 'a', 'unspace with pod =for comment');
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
93 }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
94 is(eval('foo\
95 =comment blah blah blah
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
96 .lc'), 'a', 'unspace with pod =comment');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
97 #This is pretty strange: according to Perl-6.0.0-STD.pm,
98 #unspace is allowed after a pod = ... which means pod is
99 #syntactically recursive, i.e. you can put pod comments
100 #inside pod directives recursively!
001e798 @moritz &eval does not catch exceptions.
moritz authored
101 #?rakudo skip 'pod and unspace'
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
102 is(eval('foo\
103 =\ begin comment
104 blah blah blah
105 =\ end comment
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
106 .lc'), 'a', 'unspace with pod =begin/=end comment w/ pod unspace');
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
107 #?rakudo skip '=for pod not implemented (in STD.pm)'
108 {
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
109 is(eval('foo\
110 =\ for comment
111 blah
112 blah
113 blah
114
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
115 .lc'), 'a', 'unspace with pod =for comment w/ pod unspace');
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
116 }
001e798 @moritz &eval does not catch exceptions.
moritz authored
117 #?rakudo skip 'pod and unspace'
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
118 is(eval('foo\
119 =\ comment blah blah blah
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
120 .lc'), 'a', 'unspace with pod =comment w/ pod unspace');
001e798 @moritz &eval does not catch exceptions.
moritz authored
121 #?rakudo skip 'pod and unspace'
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
122 is(eval('foo\
123 =\
efd5f21 @tadzik Remove pieces of invalid Pod
tadzik authored
124 =begin nested_pod
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
125 blah blah blah
efd5f21 @tadzik Remove pieces of invalid Pod
tadzik authored
126 =end nested_pod
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
127 begin comment
128 blah blah blah
129 =\
efd5f21 @tadzik Remove pieces of invalid Pod
tadzik authored
130 =begin nested_pod
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
131 blah blah blah
efd5f21 @tadzik Remove pieces of invalid Pod
tadzik authored
132 =end nested_pod
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
133 end comment
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
134 .lc'), 'a', 'unspace with pod =begin/=end comment w/ pod-in-pod');
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
135 #?rakudo skip '=for pod not implemented (in STD.pm)'
136 {
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
137 is(eval('foo\
138 =\
139 =for nested pod
140 blah
141 blah
142 blah
143
144 for comment
145 blah
146 blah
147 blah
148
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
149 .lc'), 'a', 'unspace with pod =for commenti w/ pod-in-pod');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
150 is(eval('foo\
151 =\
152 =nested pod blah blah blah
153 comment blah blah blah
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
154 .lc'), 'a', 'unspace with pod =comment w/ pod-in-pod');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
155 is(eval('foo\
156 =\ #1
157 =\ #2
158 =\ #3
159 =comment blah blah blah
160 for comment #3
161 blah
162 blah
163 blah
164
165 begin comment #2
166 blah blah blah
167 =\ #4
168 =comment blah blah blah
169 end comment #4
170 begin comment #1
171 blah blah blah
172 =\ #5
173 =\ #6
174 =for comment
175 blah
176 blah
177 blah
178
179 comment blah blah blah #6
180 end comment #5
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
181 .lc'), 'a', 'hideous nested pod torture test');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
182
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
183 }
13cc42c [t/spec]: Final bit of rakudo fudging in unspace.t
pmichaud authored
184
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
185 # L<S04/"Statement-ending blocks"/"Because subroutine declarations are expressions">
186 #XXX probably shouldn't be in this file...
187
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
188 eval_dies_ok('sub f { 3 } sub g { 3 }', 'semicolon or newline required between blocks');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
189
190 # L<S06/"Blocks"/"unless followed immediately by a comma">
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
191 #
f9202ea A couple of todos and skips; we can now run most of what alpha did of un...
jnthn authored
192 #?rakudo skip 'parse error'
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
193 {
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
194 sub baz(Code $x, *@y) { $x.(@y) }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
195
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
196 is((baz { @^x }, 1, 2, 3), (1, 2, 3), 'comma immediately following arg block');
197 is((baz { @^x } , 1, 2, 3), (1, 2, 3), 'comma not immediately following arg block');
198 is((baz { @^x }\ , 1, 2, 3), (1, 2, 3), 'unspace then comma following arg block');
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
199 }
200
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
201 #?rakudo skip 'indirect method calls'
0956e55 @colomon Fudge for niecza.
colomon authored
202 #?niecza skip "Invocant handling is NYI"
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
203 {
204 augment class Code{
205 method xyzzy(Code $x: *@y) { $x.(@y) }
206 }
207
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
208 is((xyzzy { @^x }: 1, 2, 3), (1, 2, 3), 'colon immediately following arg block');
209 is((xyzzy { @^x } : 1, 2, 3), (1, 2, 3), 'colon not immediately following arg block');
210 is((xyzzy { @^x }\ : 1, 2, 3), (1, 2, 3), 'unspace then colon following arg block');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
211 }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
212
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by vario...
diakopter authored
213 # L<S02/"Optional Whitespace and Exclusions"/"natural conflict between postfix operators and infix operators">
475c5dd [STD] now handles @foo non-interpolation
lwall authored
214 #This creates syntactic ambiguity between
215 # ($n) ++ ($m)
216 # ($n++) $m
217 # ($n) (++$m)
218 # ($n) + (+$m)
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
219
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
220 #?rakudo skip 'defining new operators'
221 {
222 my $n = 1;
223 my $m = 2;
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
224 sub infix:<++>($x, $y) { 42 } #OK not used
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
225
226 #'$n++$m' should be a syntax error
227 eval_dies_ok('$n++$m', 'infix requires space when ambiguous with postfix');
228 is($n, 1, 'check $n');
229 is($m, 2, 'check $m');
230
231 #'$n ++$m' should be infix:<++>
232 #no, really: http://irclog.perlgeek.de/perl6/2007-05-09#id_l328
233 $n = 1; $m = 2;
234 is(eval('$n ++$m'), 42, '$n ++$m with infix:<++> is $n ++ $m');
235 is($n, 1, 'check $n');
236 is($m, 2, 'check $m');
237
238 #'$n ++ $m' should be infix:<++>
239 $n = 1; $m = 2;
240 is(eval('$n ++ $m'), 42, 'postfix requires no space w/ infix ambiguity');
241 is($n, 1, 'check $n');
242 is($m, 2, 'check $m');
243
244 #These should all be postfix syntax errors
245 $n = 1; $m = 2;
246 eval_dies_ok('$n.++ $m', 'postfix dot w/ infix ambiguity');
247 eval_dies_ok('$n\ ++ $m', 'postfix unspace w/ infix ambiguity');
248 eval_dies_ok('$n\ .++ $m', 'postfix unspace w/ infix ambiguity');
249 is($n, 1, 'check $n');
250 is($m, 2, 'check $m');
251
252 #Unspace inside operator splits it
253 $n = 1; $m = 2;
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
254 is(($n+\ +$m), 3, 'unspace inside operator splits it');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
255 is($n, 1, 'check $n');
256 is($m, 2, 'check $m');
257
258 $n = 1;
259 eval_dies_ok('$n ++', 'postfix requires no space');
260 is($n, 1, 'check $n');
261
262 $n = 1;
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
263 is($n.++, 1, 'postfix dot');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
264 is($n, 2, 'check $n');
265
266 $n = 1;
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
267 is($n\ ++, 1, 'postfix unspace');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
268 is($n, 2, 'check $n');
269
270 $n = 1;
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
271 is($n\ .++, 1, 'postfix unspace');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
272 is($n, 2, 'check $n');
273
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by vario...
diakopter authored
274 # L<S02/"Bracketing Characters"/"U+301D codepoint has two closing alternatives">
0956e55 @colomon Fudge for niecza.
colomon authored
275 #?niecza skip 'Unable to resolve method id in class Str'
62fa996 [t/spec] embedded comments and unspaces now have a backtick
moritz authored
276 is((foo\#`〝 comment 〞.id), 'a', 'unspace with U+301D/U+301E comment');
277 eval_dies_ok('foo\#`〝 comment 〟.id', 'unspace with U+301D/U+301F is invalid');
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
278
0b24db8 @diakopter fix a lot of smartlinks in S02; some I broke and some bitrotten by vario...
diakopter authored
279 # L<S02/"Implicit Topical Method Calls"/".123">
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
280 # .123 is equal to 0.123
281
c4ff100 [t/spec] get rid of some evals in unspace.t
moritz authored
282 is ( .123), 0.123, ' .123 is equal to 0.123';
283 is (.123), 0.123, '.123 is equal to 0.123';
9bfcf50 [t/spec] some test enhancements, corrections and fudging for rakudo.
moritz authored
284 }
6ef12bd [unspace.t, unicode-whitespace.t] move to t/spec/S02-whitespace_and_comm...
rhr authored
285
17933aa [t/spec] get rid of "is also" in unspace.t
moritz authored
286 # vim: ft=perl6
Something went wrong with that request. Please try again.