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