/
999-regression.t
272 lines (211 loc) · 5.51 KB
/
999-regression.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
use v6;
use Test;
use Perl6::Parser;
use lib 't/lib';
use Utils;
my $*CONSISTENCY-CHECK = True;
my $*FALL-THROUGH = True;
# No plan here.
# We're just checking odds and ends here, so no need to rigorously check
# the object tree.
ok round-trips( Q:to[_END_] ), Q{say <closed open>};
say <closed open>;
_END_
ok round-trips( Q:to[_END_] ), Q{flat (99 ... 1)};
my @quantities = flat (99 ... 1), 'No more', 99;
_END_
ok round-trips( Q:to[_END_] ), Q{is copy};
sub foo( $a is copy ) { }
_END_
ok round-trips( gensym-package Q:to[_END_] ), Q{actions in grammars};
grammar %s {
token TOP { ^ <exp> $ { fail } }
}
_END_
# Despite how it looks, '%%' here isn't doubled-percent.
# The sprintf() format rewrites %% to %.
#
ok round-trips( gensym-package Q:to[_END_] ), Q{mod in grammar};
grammar %s {
rule exp { <term>+ %% <op> }
}
_END_
ok round-trips( Q:to[_END_] ), Q{grep: { }};
my @blocks;
@blocks.grep: { }
_END_
ok round-trips( Q:to[_END_] ), Q{my \y};
my \y = 1;
_END_
ok round-trips( gensym-package Q:to[_END_] ), Q{method fill-pixel($i)};
class %s {
method fill-pixel($i) { }
}
_END_
ok round-trips( Q:to[_END_] ), Q{quoted hash};
my %dir = (
"\e[A" => 'up',
"\e[B" => 'down',
"\e[C" => 'left',
);
_END_
ok round-trips( gensym-package Q:to[_END_] ), Q{alternation};
grammar %s { rule term { <exp> | <digits> } }
_END_
ok round-trips( Q:to[_END_] ), Q{contextualized};
say $[0];
_END_
ok round-trips( Q:to[_END_] ), Q{list reference};
my @solved = [1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,' '];
_END_
ok round-trips( Q:to[_END_] ), Q{class attribute traits};
role a_role { # role to add a variable: foo,
has $.foo is rw = 2; # with an initial value of 2
}
_END_
ok round-trips( Q:to[_END_] ), Q{infix period};
constant expansions = 1;
expansions[1].[2]
_END_
ok round-trips( Q:to[_END_] ), Q{rx with bracketed array};
my @c;
rx/<@c>/;
_END_
ok round-trips( Q:to[_END_] ), Q{range};
for 99...1 -> $bottles { }
#| Prints a verse about a certain number of beers, possibly on a wall.
_END_
ok round-trips( Q:to[_END_] ), Q{return Sub type};
sub sma(Int \P) returns Sub {
sub ($x) {
}
}
_END_
ok round-trips( Q:to[_END_] ), Q{subroutine with 'where' clause};
sub sma(Int \P where * > 0) returns Sub { }
_END_
ok round-trips( Q:to[_END_] ), Q{regex modifier};
/<[ d ]>*/
_END_
ok round-trips( Q:to[_END_] ), Q{guillemot};
my @a;
bag +« flat @a».comb: 1
_END_
ok round-trips( Q:to[_END_] ), Q{dereference};
my @x; @x.grep( +@($_) )
_END_
ok round-trips( Q:to[_END_] ), Q{semicolon in function call};
roundrobin( 1 ; 2 );
_END_
ok round-trips( Q:to[_END_] ), Q{semicolon in array slice};
my @board;
@board[*;1] = 1,2;
_END_
ok round-trips( Q:to[_END_] ), Q{here-doc with text after marker};
print qq:to/END/;
Press direction arrows to move.
Press q to quit. Press n for a new puzzle.
END
_END_
ok round-trips( Q:to[_END_] ), Q{infix-increment};
my ($x,@x);
$x.push: @x[$x] += @x.shift;
_END_
ok round-trips( Q:to[_END_] ), Q{optional arguments};
sub sing( Bool :$wall ) { }
_END_
ok round-trips( Q:to[_END_] ), Q{optional argument w/ trailing comma};
sub sing( Int $a , Int $b , Bool :$wall, ) { }
_END_
ok round-trips( Q:to[_END_] ), Q{loop};
my ($n,$k);
loop (my ($p, $f) = 2, 0; $f < $k && $p*$p <= $n; $p++) { }
_END_
ok round-trips( Q:to[_END_] ), Q{break up args};
my @a;
(sub ($w1, $w2, $w3, $w4){ })(|@a);
_END_
ok round-trips( Q:to[_END_] ), Q{meta-tilde};
("a".comb «~» "a".comb);
_END_
ok round-trips( Q:to[_END_] ), Q{postcircumfix method call};
my $x; $x()
_END_
ok round-trips( Q:to[_END_] ), Q{if-elsif};
if 1 { } elsif 2 { } elsif 3 { }
_END_
ok round-trips( Q:to[_END_] ), Q{operation: bareword};
sub infix:<lf> ($a,$b) { }
_END_
ok round-trips( Q:to[_END_] ), Q{param argument};
do -> (:value(@pa)) { };
_END_
#`( Aha, found another potential lockup
ok round-trips( Q:to[_END_] ), Q{trailing slash};
.put for slurp\
()
_END_
)
ok round-trips( Q:to[_END_] ), Q{zip-equal};
my (@a,@b);
my %h = @a Z=> @b;
_END_
ok round-trips( Q:to[_END_] ), Q{multiple ...};
do 0 => [], -> { 2 ... 1 } ... *
_END_
ok round-trips( Q:to[_END_] ), Q{posfix 'or'};
open "example.txt" , :r or 1;
_END_
ok round-trips( Q:to[_END_] ), Q{implicit return type};
sub ev (Str $s --> Num) { }
_END_
ok round-trips( Q:to[_END_] ), Q{ordered alternation};
grammar { token literal { ['.' \d+]? || '.' } }
_END_
ok round-trips( Q:to[_END_] ), Q{repeat block};
repeat { } while 1;
_END_
ok round-trips( Q:to[_END_] ), Q{postcircumfix operator};
$<bulls>
_END_
ok round-trips( Q:to[_END_] ), Q{regex with adverb};
m:s/^ \d $/
_END_
ok round-trips( Q:to[_END_] ), Q{shaped hash};
my %hash{Any};
_END_
ok round-trips( Q:to[_END_] ), Q{hyper triangle};
my $s;
1 given [\+] '\\' «leg« $s.comb;
_END_
#`( Type check fails on the interior
ok round-trips( Q:to[_END_] ), Q{whateverable prototype};
proto A { {*} }
_END_
)
ok round-trips( Q:to[_END_] ), Q{whateverable placeholder};
sub find-loop { %^mapping{*} }
_END_
#`( Another potential lockup - Add '+1' on the next line to make it compile,
yet it still locks the parser.
ok round-trips( Q:to[_END_] ), Q{Another backslash};
2 for 1\ # foo
_END_
)
ok round-trips( Q:to[_END_] ), Q{guillemot again};
sort()»<name>;
_END_
ok round-trips( Q:to[_END_] ), Q{More comma-separated lists};
sub binary_search (&p, Int $lo, Int $hi --> Int) {
}
_END_
ok round-trips( gensym-package Q:to[_END_] ), Q{Even more comma-separated lists};
class %s {
method pixel( $i, $j --> Int ) is rw { }
}
_END_
ok round-trips( Q:to[_END_] ), Q{substitution with adverb};
s:g/'[]'//
_END_
done-testing;
# vim: ft=perl6