seeing_is_believing 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Readme.md +8 -20
- data/features/examples.feature +1 -3
- data/features/flags.feature +4 -12
- data/features/regression.feature +95 -1
- data/lib/seeing_is_believing.rb +17 -21
- data/lib/seeing_is_believing/binary.rb +3 -3
- data/lib/seeing_is_believing/binary/add_annotations.rb +86 -118
- data/lib/seeing_is_believing/binary/align_chunk.rb +22 -23
- data/lib/seeing_is_believing/binary/align_file.rb +10 -13
- data/lib/seeing_is_believing/binary/align_line.rb +0 -4
- data/lib/seeing_is_believing/binary/arg_parser.rb +11 -11
- data/lib/seeing_is_believing/binary/clean_body.rb +96 -0
- data/lib/seeing_is_believing/binary/comment_formatter.rb +55 -0
- data/lib/seeing_is_believing/binary/comment_lines.rb +37 -0
- data/lib/seeing_is_believing/binary/commentable_lines.rb +158 -0
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +42 -0
- data/lib/seeing_is_believing/result.rb +2 -9
- data/lib/seeing_is_believing/the_matrix.rb +8 -8
- data/lib/seeing_is_believing/version.rb +1 -1
- data/lib/seeing_is_believing/{program_rewriter.rb → wrap_expressions.rb} +30 -22
- data/spec/binary/arg_parser_spec.rb +7 -7
- data/spec/binary/clean_body_spec.rb +217 -0
- data/spec/binary/comment_formatter_spec.rb +54 -0
- data/spec/binary/comment_lines_spec.rb +847 -0
- data/spec/binary/rewrite_comments_spec.rb +54 -0
- data/spec/seeing_is_believing_spec.rb +1 -2
- data/spec/{program_rewriter_spec.rb → wrap_expressions_spec.rb} +117 -40
- metadata +41 -56
- data/lib/seeing_is_believing/binary/line_formatter.rb +0 -47
- data/lib/seeing_is_believing/binary/remove_previous_annotations.rb +0 -75
- data/lib/seeing_is_believing/queue.rb +0 -55
- data/lib/seeing_is_believing/remove_inline_comments.rb +0 -46
- data/lib/seeing_is_believing/syntax_analyzer.rb +0 -61
- data/lib/seeing_is_believing/tracks_line_numbers_seen.rb +0 -19
- data/spec/binary/line_formatter_spec.rb +0 -53
- data/spec/binary/remove_previous_annotations_spec.rb +0 -198
- data/spec/queue_spec.rb +0 -80
- data/spec/syntax_analyzer_spec.rb +0 -56
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'seeing_is_believing/binary/comment_formatter'
|
2
|
+
|
3
|
+
describe SeeingIsBelieving::Binary::CommentFormatter do
|
4
|
+
def result_for(line, separator, result, options={})
|
5
|
+
described_class.new(line, separator, result, options).call
|
6
|
+
end
|
7
|
+
|
8
|
+
specify 'it returns the consolidated result if there are no truncations' do
|
9
|
+
result_for(1, '=>', '12345').should == '=>12345'
|
10
|
+
end
|
11
|
+
|
12
|
+
specify 'result_length truncates a result to the specified length, using elipses up to that length if appropriate' do
|
13
|
+
line_length = 1
|
14
|
+
separator = '=>'
|
15
|
+
result = '12345'
|
16
|
+
result_for(line_length, separator, result, max_result_length: Float::INFINITY).should == '=>12345'
|
17
|
+
result_for(line_length, separator, result, max_result_length: 7).should == '=>12345'
|
18
|
+
result_for(line_length, separator, result, max_result_length: 6).should == '=>1...'
|
19
|
+
result_for(line_length, separator, result, max_result_length: 5).should == '=>...'
|
20
|
+
result_for(line_length, separator, result, max_result_length: 4).should == ''
|
21
|
+
result_for(line_length, separator, result, max_result_length: 0).should == ''
|
22
|
+
end
|
23
|
+
|
24
|
+
specify 'line_length truncates a result to the specified length, minus the length of the line' do
|
25
|
+
line_length = 1
|
26
|
+
separator = '=>'
|
27
|
+
result = '12345'
|
28
|
+
result_for(line_length, separator, result).should == '=>12345'
|
29
|
+
result_for(line_length, separator, result, max_line_length: Float::INFINITY).should == '=>12345'
|
30
|
+
result_for(line_length, separator, result, max_line_length: 8).should == '=>12345'
|
31
|
+
result_for(line_length, separator, result, max_line_length: 7).should == '=>1...'
|
32
|
+
result_for(line_length, separator, result, max_line_length: 6).should == '=>...'
|
33
|
+
result_for(line_length, separator, result, max_line_length: 5).should == ''
|
34
|
+
result_for(line_length, separator, result, max_line_length: 0).should == ''
|
35
|
+
end
|
36
|
+
|
37
|
+
specify 'pad_to will pad the length that the line is displayed in' do
|
38
|
+
result_for(1, '=>', '2', pad_to: 0).should == '=>2'
|
39
|
+
result_for(1, '=>', '2', pad_to: 1).should == '=>2'
|
40
|
+
result_for(1, '=>', '2', pad_to: 2).should == ' =>2'
|
41
|
+
end
|
42
|
+
|
43
|
+
specify 'pad_to is ignored when separator/result will not be printed' do
|
44
|
+
result_for(1, '=>', '12345', pad_to: 2, max_line_length: 2).should == ''
|
45
|
+
result_for(1, '=>', '12345', pad_to: 2, max_result_length: 2).should == ''
|
46
|
+
end
|
47
|
+
|
48
|
+
specify 'they can all work together' do
|
49
|
+
result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 100, pad_to: 2).should == ' =>12345'
|
50
|
+
result_for(1, '=>', '12345', max_line_length: 8, max_result_length: 100, pad_to: 2).should == ' =>1...'
|
51
|
+
result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).should == ' =>1...'
|
52
|
+
result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).should == ' =>1...'
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,847 @@
|
|
1
|
+
require 'seeing_is_believing/binary/comment_lines'
|
2
|
+
|
3
|
+
# FIXME: For now ignoring heredocs
|
4
|
+
# because we know the user of this class won't have output on them
|
5
|
+
# and it's a PITA to deal with.
|
6
|
+
# Eventually, though, Parser should take this into account
|
7
|
+
describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentable line and the line number, and adds the returned text (whitespace+comment) to the end' do
|
8
|
+
def call(code, &block)
|
9
|
+
described_class.call code, &block
|
10
|
+
end
|
11
|
+
|
12
|
+
example 'just checking some edge cases' do
|
13
|
+
call("") { ';' }.should == ";"
|
14
|
+
call("__END__\n1") { ';' }.should == "__END__\n1"
|
15
|
+
call("1\n__END__") { ';' }.should == "1;\n__END__"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "doesn't comment lines whose newline is escaped" do
|
19
|
+
call("1 +\\\n2") { |_, line_number| "--#{line_number}--" }.should == "1 +\\\n2--2--"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't comment lines inside of strings" do
|
23
|
+
call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
|
24
|
+
"a\#{1+1
|
25
|
+
}"
|
26
|
+
"a
|
27
|
+
b"
|
28
|
+
'a
|
29
|
+
b'
|
30
|
+
%Q{
|
31
|
+
}
|
32
|
+
%q{
|
33
|
+
}
|
34
|
+
%.
|
35
|
+
.
|
36
|
+
INPUT
|
37
|
+
"a\#{1+1
|
38
|
+
}"--2--
|
39
|
+
"a
|
40
|
+
b"--4--
|
41
|
+
'a
|
42
|
+
b'--6--
|
43
|
+
%Q{
|
44
|
+
}--8--
|
45
|
+
%q{
|
46
|
+
}--10--
|
47
|
+
%.
|
48
|
+
.--12--
|
49
|
+
OUTPUT
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'does comment the first line of a heredoc' do
|
53
|
+
call(<<-INPUT.gsub(/^ */, '')) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT.gsub(/^ */, '')
|
54
|
+
<<A
|
55
|
+
1
|
56
|
+
A
|
57
|
+
<<-A
|
58
|
+
1
|
59
|
+
A
|
60
|
+
<<A.b
|
61
|
+
1
|
62
|
+
A
|
63
|
+
b <<A
|
64
|
+
1
|
65
|
+
A
|
66
|
+
<<A.b <<C
|
67
|
+
1
|
68
|
+
A
|
69
|
+
2
|
70
|
+
C
|
71
|
+
a(<<B)
|
72
|
+
1
|
73
|
+
B
|
74
|
+
INPUT
|
75
|
+
<<A--1--
|
76
|
+
1
|
77
|
+
A
|
78
|
+
<<-A--4--
|
79
|
+
1
|
80
|
+
A
|
81
|
+
<<A.b--7--
|
82
|
+
1
|
83
|
+
A
|
84
|
+
b <<A--10--
|
85
|
+
1
|
86
|
+
A
|
87
|
+
<<A.b <<C--13--
|
88
|
+
1
|
89
|
+
A
|
90
|
+
2
|
91
|
+
C
|
92
|
+
a(<<B)--18--
|
93
|
+
1
|
94
|
+
B
|
95
|
+
OUTPUT
|
96
|
+
end
|
97
|
+
|
98
|
+
it "doesn't comment lines inside of regexes" do
|
99
|
+
call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
|
100
|
+
/a\#{1+1
|
101
|
+
}/
|
102
|
+
/a
|
103
|
+
b/ix
|
104
|
+
%r.
|
105
|
+
.
|
106
|
+
INPUT
|
107
|
+
/a\#{1+1
|
108
|
+
}/--2--
|
109
|
+
/a
|
110
|
+
b/ix--4--
|
111
|
+
%r.
|
112
|
+
.--6--
|
113
|
+
OUTPUT
|
114
|
+
end
|
115
|
+
|
116
|
+
it "doesn't comment lines inside of backticks/%x" do
|
117
|
+
call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
|
118
|
+
`a\#{1+1
|
119
|
+
}`
|
120
|
+
%x[\#{1+1
|
121
|
+
}]
|
122
|
+
`
|
123
|
+
b
|
124
|
+
c`
|
125
|
+
%x.
|
126
|
+
b
|
127
|
+
c.
|
128
|
+
INPUT
|
129
|
+
`a\#{1+1
|
130
|
+
}`--2--
|
131
|
+
%x[\#{1+1
|
132
|
+
}]--4--
|
133
|
+
`
|
134
|
+
b
|
135
|
+
c`--7--
|
136
|
+
%x.
|
137
|
+
b
|
138
|
+
c.--10--
|
139
|
+
OUTPUT
|
140
|
+
end
|
141
|
+
|
142
|
+
it "doesn't comment lines inside of string arrays" do
|
143
|
+
call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
|
144
|
+
%w[
|
145
|
+
a
|
146
|
+
]
|
147
|
+
INPUT
|
148
|
+
%w[
|
149
|
+
a
|
150
|
+
]--3--
|
151
|
+
OUTPUT
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
it 'yields the line and line number to the commenter block' do
|
156
|
+
lines = []
|
157
|
+
result = call("1 +\n"\
|
158
|
+
" 2\n"\
|
159
|
+
"\n"\
|
160
|
+
"# just a comment\n"\
|
161
|
+
"3 # already has a comment\n"\
|
162
|
+
"'4\n"\
|
163
|
+
"5'+\n"\
|
164
|
+
"%Q'\n"\
|
165
|
+
" \#{5+6} 7'\n") do |line, line_number|
|
166
|
+
lines << line
|
167
|
+
"--#{line_number}--"
|
168
|
+
end
|
169
|
+
|
170
|
+
lines.should == [ "1 +",
|
171
|
+
" 2",
|
172
|
+
"",
|
173
|
+
"5'+",
|
174
|
+
" \#{5+6} 7'"]
|
175
|
+
|
176
|
+
result.should == "1 +--1--\n"\
|
177
|
+
" 2--2--\n"\
|
178
|
+
"--3--\n"\
|
179
|
+
"# just a comment\n"\
|
180
|
+
"3 # already has a comment\n"\
|
181
|
+
"'4\n"\
|
182
|
+
"5'+--7--\n"\
|
183
|
+
"%Q'\n"\
|
184
|
+
" \#{5+6} 7'--9--\n"
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
example 'big comprehensive example' do
|
189
|
+
input=<<INPUT
|
190
|
+
|
191
|
+
# comment
|
192
|
+
1 # comment after line
|
193
|
+
=begin
|
194
|
+
multiline comment
|
195
|
+
=end
|
196
|
+
|
197
|
+
1;
|
198
|
+
|
199
|
+
class A
|
200
|
+
end
|
201
|
+
A
|
202
|
+
|
203
|
+
class B < A
|
204
|
+
def m
|
205
|
+
end
|
206
|
+
def m1(a, b=1, *c, d, &e)
|
207
|
+
end
|
208
|
+
def m2() 1
|
209
|
+
end
|
210
|
+
def m3(a,
|
211
|
+
b)
|
212
|
+
end
|
213
|
+
|
214
|
+
public
|
215
|
+
private
|
216
|
+
protected
|
217
|
+
class << self
|
218
|
+
1
|
219
|
+
super
|
220
|
+
yield
|
221
|
+
return 2
|
222
|
+
return
|
223
|
+
rescue
|
224
|
+
3
|
225
|
+
ensure
|
226
|
+
4
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
module C
|
231
|
+
include Comparable
|
232
|
+
extend Comparable
|
233
|
+
end
|
234
|
+
|
235
|
+
a
|
236
|
+
a.b
|
237
|
+
a.b 1
|
238
|
+
b 2
|
239
|
+
b 2, 3
|
240
|
+
b(2, 3)
|
241
|
+
b(2, 3) { |a| }
|
242
|
+
a { }
|
243
|
+
b { |a|
|
244
|
+
}
|
245
|
+
b do |arg| end
|
246
|
+
b do |arg|
|
247
|
+
end
|
248
|
+
|
249
|
+
-> a {
|
250
|
+
}
|
251
|
+
-> { }.()
|
252
|
+
|
253
|
+
123
|
254
|
+
-123
|
255
|
+
1_123
|
256
|
+
-543
|
257
|
+
123_456_789_123_456_789
|
258
|
+
123.45
|
259
|
+
1.2e-3
|
260
|
+
0xaabb
|
261
|
+
0377
|
262
|
+
-0b1010
|
263
|
+
0b001_001
|
264
|
+
?a
|
265
|
+
?\\C-a
|
266
|
+
?\\M-a
|
267
|
+
?\\M-\\C-a
|
268
|
+
1..2
|
269
|
+
1...2
|
270
|
+
(true==true)..(1==2)
|
271
|
+
true
|
272
|
+
false
|
273
|
+
nil
|
274
|
+
self
|
275
|
+
[1,2,3]
|
276
|
+
[1,*a,*[2,3,4]]
|
277
|
+
%w(1)
|
278
|
+
%W(2)
|
279
|
+
%x[ls]
|
280
|
+
/abc/
|
281
|
+
%r(abc)
|
282
|
+
%r.abc.
|
283
|
+
:abc
|
284
|
+
:'abc'
|
285
|
+
:"abc"
|
286
|
+
:"a\#{1}"
|
287
|
+
{1=>2}
|
288
|
+
{a:1}
|
289
|
+
__FILE__
|
290
|
+
__LINE__
|
291
|
+
defined? a
|
292
|
+
|
293
|
+
# some void values
|
294
|
+
loop {
|
295
|
+
next
|
296
|
+
}
|
297
|
+
loop {
|
298
|
+
redo
|
299
|
+
}
|
300
|
+
loop {
|
301
|
+
break
|
302
|
+
}
|
303
|
+
|
304
|
+
# conditionals
|
305
|
+
1 if a
|
306
|
+
if a
|
307
|
+
end
|
308
|
+
if (a)
|
309
|
+
end
|
310
|
+
if (a &&
|
311
|
+
b)
|
312
|
+
end
|
313
|
+
if a == b
|
314
|
+
1
|
315
|
+
elsif b != c
|
316
|
+
2
|
317
|
+
else
|
318
|
+
3
|
319
|
+
4
|
320
|
+
end
|
321
|
+
unless a && b || c
|
322
|
+
1
|
323
|
+
else
|
324
|
+
2
|
325
|
+
end
|
326
|
+
1 ? 2 : 3
|
327
|
+
1 ?
|
328
|
+
2 :
|
329
|
+
3
|
330
|
+
|
331
|
+
# begin/rescue/end
|
332
|
+
begin
|
333
|
+
1
|
334
|
+
rescue
|
335
|
+
2
|
336
|
+
rescue a
|
337
|
+
3
|
338
|
+
rescue => a
|
339
|
+
4
|
340
|
+
rescue Exception
|
341
|
+
5
|
342
|
+
rescue Exception => a
|
343
|
+
6
|
344
|
+
else
|
345
|
+
7
|
346
|
+
ensure
|
347
|
+
8
|
348
|
+
end
|
349
|
+
1 rescue nil
|
350
|
+
|
351
|
+
(a
|
352
|
+
b)
|
353
|
+
(a
|
354
|
+
b
|
355
|
+
)
|
356
|
+
a;b
|
357
|
+
alias a b
|
358
|
+
undef whatev
|
359
|
+
`a`
|
360
|
+
`a
|
361
|
+
b`
|
362
|
+
`a \#{
|
363
|
+
123
|
364
|
+
}
|
365
|
+
`
|
366
|
+
%x[
|
367
|
+
a
|
368
|
+
\#{
|
369
|
+
123
|
370
|
+
}
|
371
|
+
b
|
372
|
+
]
|
373
|
+
$a
|
374
|
+
@a
|
375
|
+
@@a
|
376
|
+
|
377
|
+
a
|
378
|
+
a()
|
379
|
+
a.b
|
380
|
+
a.b!
|
381
|
+
a.b?
|
382
|
+
a.b()
|
383
|
+
a b
|
384
|
+
a(b,c,*d,&e)
|
385
|
+
a b,c,*d,&e
|
386
|
+
a b,c,*d do
|
387
|
+
end
|
388
|
+
a.b c,d,*e do
|
389
|
+
end
|
390
|
+
a.b(c,d,*e) { }
|
391
|
+
a.b {
|
392
|
+
123
|
393
|
+
}
|
394
|
+
1+1
|
395
|
+
a.b+1
|
396
|
+
a.b-1
|
397
|
+
a.b - 1
|
398
|
+
!1
|
399
|
+
~1
|
400
|
+
a.b 1,
|
401
|
+
2,
|
402
|
+
3 => 4
|
403
|
+
a.b(
|
404
|
+
1,
|
405
|
+
2)
|
406
|
+
a { |
|
407
|
+
b|
|
408
|
+
}
|
409
|
+
a=1
|
410
|
+
a.b=1
|
411
|
+
A
|
412
|
+
A=1
|
413
|
+
A::B
|
414
|
+
A::B=1
|
415
|
+
@a=1
|
416
|
+
@@a=1
|
417
|
+
$a=1
|
418
|
+
a,@b=1,2
|
419
|
+
a=
|
420
|
+
1
|
421
|
+
a=b=1
|
422
|
+
a += 1
|
423
|
+
a *= 1
|
424
|
+
a -= 1
|
425
|
+
a /= 1
|
426
|
+
a **= 1
|
427
|
+
a |= 1
|
428
|
+
a &= 1
|
429
|
+
a ||= 1
|
430
|
+
a &&= 1
|
431
|
+
a[1] = 2
|
432
|
+
a[1] ||= 2
|
433
|
+
a[
|
434
|
+
1,
|
435
|
+
2] = 3
|
436
|
+
1 if /abc/
|
437
|
+
case a
|
438
|
+
when b
|
439
|
+
1
|
440
|
+
when c then d
|
441
|
+
2
|
442
|
+
else
|
443
|
+
3
|
444
|
+
end
|
445
|
+
if 1 and
|
446
|
+
2 or
|
447
|
+
3
|
448
|
+
3
|
449
|
+
end
|
450
|
+
if 1 then
|
451
|
+
2
|
452
|
+
end
|
453
|
+
|
454
|
+
1 until 2
|
455
|
+
1 while 2
|
456
|
+
until 1
|
457
|
+
2
|
458
|
+
end
|
459
|
+
while 1
|
460
|
+
2
|
461
|
+
end
|
462
|
+
for a in [1,2,3]
|
463
|
+
redo
|
464
|
+
end
|
465
|
+
for a in [1,2,3] do
|
466
|
+
redo
|
467
|
+
break
|
468
|
+
break 10
|
469
|
+
next
|
470
|
+
next 10
|
471
|
+
end
|
472
|
+
{1 =>
|
473
|
+
2,
|
474
|
+
3 => 4,
|
475
|
+
a:
|
476
|
+
1,
|
477
|
+
b: 2,
|
478
|
+
}
|
479
|
+
puts(a: b)
|
480
|
+
puts a: b
|
481
|
+
[1,
|
482
|
+
2,
|
483
|
+
*abc
|
484
|
+
]
|
485
|
+
|
486
|
+
/a
|
487
|
+
\#{
|
488
|
+
123
|
489
|
+
}/x
|
490
|
+
%r.1
|
491
|
+
2
|
492
|
+
.i
|
493
|
+
|
494
|
+
"a
|
495
|
+
b"
|
496
|
+
"a\#{
|
497
|
+
123
|
498
|
+
}
|
499
|
+
\#{123}"
|
500
|
+
'a
|
501
|
+
b'
|
502
|
+
%.
|
503
|
+
a\#{
|
504
|
+
123
|
505
|
+
}.
|
506
|
+
%Q.
|
507
|
+
a\#{
|
508
|
+
123
|
509
|
+
}.
|
510
|
+
%q.
|
511
|
+
1
|
512
|
+
.
|
513
|
+
__END__
|
514
|
+
1
|
515
|
+
INPUT
|
516
|
+
|
517
|
+
output=<<OUTPUT
|
518
|
+
;
|
519
|
+
# comment
|
520
|
+
1 # comment after line
|
521
|
+
=begin
|
522
|
+
multiline comment
|
523
|
+
=end
|
524
|
+
;
|
525
|
+
1;;
|
526
|
+
;
|
527
|
+
class A;
|
528
|
+
end;
|
529
|
+
A;
|
530
|
+
;
|
531
|
+
class B < A;
|
532
|
+
def m;
|
533
|
+
end;
|
534
|
+
def m1(a, b=1, *c, d, &e);
|
535
|
+
end;
|
536
|
+
def m2() 1;
|
537
|
+
end;
|
538
|
+
def m3(a,;
|
539
|
+
b);
|
540
|
+
end;
|
541
|
+
;
|
542
|
+
public;
|
543
|
+
private;
|
544
|
+
protected;
|
545
|
+
class << self;
|
546
|
+
1;
|
547
|
+
super;
|
548
|
+
yield;
|
549
|
+
return 2;
|
550
|
+
return;
|
551
|
+
rescue;
|
552
|
+
3;
|
553
|
+
ensure;
|
554
|
+
4;
|
555
|
+
end;
|
556
|
+
end;
|
557
|
+
;
|
558
|
+
module C;
|
559
|
+
include Comparable;
|
560
|
+
extend Comparable;
|
561
|
+
end;
|
562
|
+
;
|
563
|
+
a;
|
564
|
+
a.b;
|
565
|
+
a.b 1;
|
566
|
+
b 2;
|
567
|
+
b 2, 3;
|
568
|
+
b(2, 3);
|
569
|
+
b(2, 3) { |a| };
|
570
|
+
a { };
|
571
|
+
b { |a|;
|
572
|
+
};
|
573
|
+
b do |arg| end;
|
574
|
+
b do |arg|;
|
575
|
+
end;
|
576
|
+
;
|
577
|
+
-> a {;
|
578
|
+
};
|
579
|
+
-> { }.();
|
580
|
+
;
|
581
|
+
123;
|
582
|
+
-123;
|
583
|
+
1_123;
|
584
|
+
-543;
|
585
|
+
123_456_789_123_456_789;
|
586
|
+
123.45;
|
587
|
+
1.2e-3;
|
588
|
+
0xaabb;
|
589
|
+
0377;
|
590
|
+
-0b1010;
|
591
|
+
0b001_001;
|
592
|
+
?a;
|
593
|
+
?\\C-a;
|
594
|
+
?\\M-a;
|
595
|
+
?\\M-\\C-a;
|
596
|
+
1..2;
|
597
|
+
1...2;
|
598
|
+
(true==true)..(1==2);
|
599
|
+
true;
|
600
|
+
false;
|
601
|
+
nil;
|
602
|
+
self;
|
603
|
+
[1,2,3];
|
604
|
+
[1,*a,*[2,3,4]];
|
605
|
+
%w(1);
|
606
|
+
%W(2);
|
607
|
+
%x[ls];
|
608
|
+
/abc/;
|
609
|
+
%r(abc);
|
610
|
+
%r.abc.;
|
611
|
+
:abc;
|
612
|
+
:'abc';
|
613
|
+
:"abc";
|
614
|
+
:"a\#{1}";
|
615
|
+
{1=>2};
|
616
|
+
{a:1};
|
617
|
+
__FILE__;
|
618
|
+
__LINE__;
|
619
|
+
defined? a;
|
620
|
+
;
|
621
|
+
# some void values
|
622
|
+
loop {;
|
623
|
+
next;
|
624
|
+
};
|
625
|
+
loop {;
|
626
|
+
redo;
|
627
|
+
};
|
628
|
+
loop {;
|
629
|
+
break;
|
630
|
+
};
|
631
|
+
;
|
632
|
+
# conditionals
|
633
|
+
1 if a;
|
634
|
+
if a;
|
635
|
+
end;
|
636
|
+
if (a);
|
637
|
+
end;
|
638
|
+
if (a &&;
|
639
|
+
b);
|
640
|
+
end;
|
641
|
+
if a == b;
|
642
|
+
1;
|
643
|
+
elsif b != c;
|
644
|
+
2;
|
645
|
+
else;
|
646
|
+
3;
|
647
|
+
4;
|
648
|
+
end;
|
649
|
+
unless a && b || c;
|
650
|
+
1;
|
651
|
+
else;
|
652
|
+
2;
|
653
|
+
end;
|
654
|
+
1 ? 2 : 3;
|
655
|
+
1 ?;
|
656
|
+
2 :;
|
657
|
+
3;
|
658
|
+
;
|
659
|
+
# begin/rescue/end
|
660
|
+
begin;
|
661
|
+
1;
|
662
|
+
rescue;
|
663
|
+
2;
|
664
|
+
rescue a;
|
665
|
+
3;
|
666
|
+
rescue => a;
|
667
|
+
4;
|
668
|
+
rescue Exception;
|
669
|
+
5;
|
670
|
+
rescue Exception => a;
|
671
|
+
6;
|
672
|
+
else;
|
673
|
+
7;
|
674
|
+
ensure;
|
675
|
+
8;
|
676
|
+
end;
|
677
|
+
1 rescue nil;
|
678
|
+
;
|
679
|
+
(a;
|
680
|
+
b);
|
681
|
+
(a;
|
682
|
+
b;
|
683
|
+
);
|
684
|
+
a;b;
|
685
|
+
alias a b;
|
686
|
+
undef whatev;
|
687
|
+
`a`;
|
688
|
+
`a
|
689
|
+
b`;
|
690
|
+
`a \#{
|
691
|
+
123
|
692
|
+
}
|
693
|
+
`;
|
694
|
+
%x[
|
695
|
+
a
|
696
|
+
\#{
|
697
|
+
123
|
698
|
+
}
|
699
|
+
b
|
700
|
+
];
|
701
|
+
$a;
|
702
|
+
@a;
|
703
|
+
@@a;
|
704
|
+
;
|
705
|
+
a;
|
706
|
+
a();
|
707
|
+
a.b;
|
708
|
+
a.b!;
|
709
|
+
a.b?;
|
710
|
+
a.b();
|
711
|
+
a b;
|
712
|
+
a(b,c,*d,&e);
|
713
|
+
a b,c,*d,&e;
|
714
|
+
a b,c,*d do;
|
715
|
+
end;
|
716
|
+
a.b c,d,*e do;
|
717
|
+
end;
|
718
|
+
a.b(c,d,*e) { };
|
719
|
+
a.b {;
|
720
|
+
123;
|
721
|
+
};
|
722
|
+
1+1;
|
723
|
+
a.b+1;
|
724
|
+
a.b-1;
|
725
|
+
a.b - 1;
|
726
|
+
!1;
|
727
|
+
~1;
|
728
|
+
a.b 1,;
|
729
|
+
2,;
|
730
|
+
3 => 4;
|
731
|
+
a.b(;
|
732
|
+
1,;
|
733
|
+
2);
|
734
|
+
a { |;
|
735
|
+
b|;
|
736
|
+
};
|
737
|
+
a=1;
|
738
|
+
a.b=1;
|
739
|
+
A;
|
740
|
+
A=1;
|
741
|
+
A::B;
|
742
|
+
A::B=1;
|
743
|
+
@a=1;
|
744
|
+
@@a=1;
|
745
|
+
$a=1;
|
746
|
+
a,@b=1,2;
|
747
|
+
a=;
|
748
|
+
1;
|
749
|
+
a=b=1;
|
750
|
+
a += 1;
|
751
|
+
a *= 1;
|
752
|
+
a -= 1;
|
753
|
+
a /= 1;
|
754
|
+
a **= 1;
|
755
|
+
a |= 1;
|
756
|
+
a &= 1;
|
757
|
+
a ||= 1;
|
758
|
+
a &&= 1;
|
759
|
+
a[1] = 2;
|
760
|
+
a[1] ||= 2;
|
761
|
+
a[;
|
762
|
+
1,;
|
763
|
+
2] = 3;
|
764
|
+
1 if /abc/;
|
765
|
+
case a;
|
766
|
+
when b;
|
767
|
+
1;
|
768
|
+
when c then d;
|
769
|
+
2;
|
770
|
+
else;
|
771
|
+
3;
|
772
|
+
end;
|
773
|
+
if 1 and;
|
774
|
+
2 or;
|
775
|
+
3;
|
776
|
+
3;
|
777
|
+
end;
|
778
|
+
if 1 then;
|
779
|
+
2;
|
780
|
+
end;
|
781
|
+
;
|
782
|
+
1 until 2;
|
783
|
+
1 while 2;
|
784
|
+
until 1;
|
785
|
+
2;
|
786
|
+
end;
|
787
|
+
while 1;
|
788
|
+
2;
|
789
|
+
end;
|
790
|
+
for a in [1,2,3];
|
791
|
+
redo;
|
792
|
+
end;
|
793
|
+
for a in [1,2,3] do;
|
794
|
+
redo;
|
795
|
+
break;
|
796
|
+
break 10;
|
797
|
+
next;
|
798
|
+
next 10;
|
799
|
+
end;
|
800
|
+
{1 =>;
|
801
|
+
2,;
|
802
|
+
3 => 4,;
|
803
|
+
a:;
|
804
|
+
1,;
|
805
|
+
b: 2,;
|
806
|
+
};
|
807
|
+
puts(a: b);
|
808
|
+
puts a: b;
|
809
|
+
[1,;
|
810
|
+
2,;
|
811
|
+
*abc;
|
812
|
+
];
|
813
|
+
;
|
814
|
+
/a
|
815
|
+
\#{
|
816
|
+
123
|
817
|
+
}/x;
|
818
|
+
%r.1
|
819
|
+
2
|
820
|
+
.i;
|
821
|
+
;
|
822
|
+
"a
|
823
|
+
b";
|
824
|
+
"a\#{
|
825
|
+
123
|
826
|
+
}
|
827
|
+
\#{123}";
|
828
|
+
'a
|
829
|
+
b';
|
830
|
+
%.
|
831
|
+
a\#{
|
832
|
+
123
|
833
|
+
}.;
|
834
|
+
%Q.
|
835
|
+
a\#{
|
836
|
+
123
|
837
|
+
}.;
|
838
|
+
%q.
|
839
|
+
1
|
840
|
+
.;
|
841
|
+
__END__
|
842
|
+
1
|
843
|
+
OUTPUT
|
844
|
+
|
845
|
+
call(input) { ';' }.should == output
|
846
|
+
end
|
847
|
+
end
|