rubinius-melbourne 2.0.0.19 → 2.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +14 -0
  4. data/Gemfile +4 -0
  5. data/Rakefile +31 -0
  6. data/ext/rubinius/melbourne/extconf.rb +9 -2
  7. data/lib/rubinius/melbourne.rb +1 -1
  8. data/lib/rubinius/melbourne/version.rb +1 -1
  9. data/rubinius-melbourne.gemspec +5 -3
  10. data/spec/alias_spec.rb +40 -0
  11. data/spec/and_spec.rb +19 -0
  12. data/spec/array_spec.rb +81 -0
  13. data/spec/attrasgn_spec.rb +112 -0
  14. data/spec/back_ref_spec.rb +11 -0
  15. data/spec/call_spec.rb +298 -0
  16. data/spec/case_spec.rb +234 -0
  17. data/spec/cdecl_spec.rb +45 -0
  18. data/spec/class_spec.rb +83 -0
  19. data/spec/colon2_spec.rb +7 -0
  20. data/spec/colon3_spec.rb +7 -0
  21. data/spec/const_spec.rb +7 -0
  22. data/spec/custom/matchers/parse_as.rb +27 -0
  23. data/spec/custom/runner/relates.rb +83 -0
  24. data/spec/cvar_spec.rb +29 -0
  25. data/spec/cvasgn_spec.rb +30 -0
  26. data/spec/cvdecl_spec.rb +12 -0
  27. data/spec/default.mspec +4 -0
  28. data/spec/defined_spec.rb +117 -0
  29. data/spec/defn_spec.rb +554 -0
  30. data/spec/defs_spec.rb +81 -0
  31. data/spec/dot2_spec.rb +7 -0
  32. data/spec/dot3_spec.rb +7 -0
  33. data/spec/dregx_spec.rb +52 -0
  34. data/spec/dstr_spec.rb +169 -0
  35. data/spec/dsym_spec.rb +10 -0
  36. data/spec/dxstr_spec.rb +11 -0
  37. data/spec/ensure_spec.rb +117 -0
  38. data/spec/false_spec.rb +7 -0
  39. data/spec/flip2_spec.rb +43 -0
  40. data/spec/flip3_spec.rb +27 -0
  41. data/spec/for_spec.rb +61 -0
  42. data/spec/gasgn_spec.rb +13 -0
  43. data/spec/gvar_spec.rb +25 -0
  44. data/spec/hash_spec.rb +31 -0
  45. data/spec/iasgn_spec.rb +25 -0
  46. data/spec/if_spec.rb +131 -0
  47. data/spec/iter_spec.rb +613 -0
  48. data/spec/lasgn_spec.rb +377 -0
  49. data/spec/lit_spec.rb +61 -0
  50. data/spec/masgn_spec.rb +406 -0
  51. data/spec/match2_spec.rb +19 -0
  52. data/spec/match3_spec.rb +24 -0
  53. data/spec/match_spec.rb +7 -0
  54. data/spec/module_spec.rb +47 -0
  55. data/spec/nil_spec.rb +7 -0
  56. data/spec/not_spec.rb +17 -0
  57. data/spec/nth_ref_spec.rb +7 -0
  58. data/spec/op_asgn_spec.rb +246 -0
  59. data/spec/or_spec.rb +35 -0
  60. data/spec/postexe_spec.rb +7 -0
  61. data/spec/regex_spec.rb +28 -0
  62. data/spec/rescue_spec.rb +359 -0
  63. data/spec/return_spec.rb +57 -0
  64. data/spec/sclass_spec.rb +55 -0
  65. data/spec/str_spec.rb +97 -0
  66. data/spec/super_spec.rb +93 -0
  67. data/spec/true_spec.rb +7 -0
  68. data/spec/undef_spec.rb +98 -0
  69. data/spec/until_spec.rb +140 -0
  70. data/spec/valias_spec.rb +7 -0
  71. data/spec/while_spec.rb +192 -0
  72. data/spec/xstr_spec.rb +7 -0
  73. data/spec/yield_spec.rb +65 -0
  74. data/spec/zsuper_spec.rb +45 -0
  75. metadata +171 -13
data/spec/cvar_spec.rb ADDED
@@ -0,0 +1,29 @@
1
+ describe "A Cvar node" do
2
+ relates "@@x" do
3
+ parse do
4
+ [:cvar, :@@x]
5
+ end
6
+ end
7
+
8
+ relates <<-ruby do
9
+ class A
10
+ @@a
11
+ end
12
+ ruby
13
+
14
+ parse do
15
+ [:class, :A, nil, [:scope, [:cvar, :@@a]]]
16
+ end
17
+ end
18
+
19
+ relates <<-ruby do
20
+ module M
21
+ @@a
22
+ end
23
+ ruby
24
+
25
+ parse do
26
+ [:module, :M, [:scope, [:cvar, :@@a]]]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ describe "A Cvasgn node" do
2
+ relates <<-ruby do
3
+ def x
4
+ @@blah = 1
5
+ end
6
+ ruby
7
+
8
+ parse do
9
+ [:defn,
10
+ :x,
11
+ [:args],
12
+ [:scope, [:block, [:cvasgn, :@@blah, [:lit, 1]]]]]
13
+ end
14
+ end
15
+
16
+ relates <<-ruby do
17
+ def self.quiet_mode=(boolean)
18
+ @@quiet_mode = boolean
19
+ end
20
+ ruby
21
+
22
+ parse do
23
+ [:defs,
24
+ [:self],
25
+ :quiet_mode=,
26
+ [:args, :boolean],
27
+ [:scope, [:block, [:cvasgn, :@@quiet_mode, [:lvar, :boolean]]]]]
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ describe "A Cvdecl node" do
2
+ relates <<-ruby do
3
+ class X
4
+ @@blah = 1
5
+ end
6
+ ruby
7
+
8
+ parse do
9
+ [:class, :X, nil, [:scope, [:cvdecl, :@@blah, [:lit, 1]]]]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # vim: filetype=ruby
2
+
3
+ require 'spec/custom/matchers/parse_as'
4
+ require 'spec/custom/runner/relates'
@@ -0,0 +1,117 @@
1
+ describe "A Defined node" do
2
+ relates "defined? $x" do
3
+ parse do
4
+ [:defined, [:gvar, :$x]]
5
+ end
6
+ end
7
+
8
+ relates "defined? a" do
9
+ # TODO
10
+ end
11
+
12
+ relates <<-ruby do
13
+ a = 1
14
+ defined? a
15
+ ruby
16
+ end
17
+
18
+ relates "defined? x = 1" do
19
+ # TODO
20
+ end
21
+
22
+ relates "defined? x += 1" do
23
+ # TODO
24
+ end
25
+
26
+ relates "defined? x ||= 1" do
27
+ # TODO
28
+ end
29
+
30
+ relates "defined? x &&= 1" do
31
+ # TODO
32
+ end
33
+
34
+ relates "defined? X" do
35
+ # TODO
36
+ end
37
+
38
+ relates "defined? ::X" do
39
+ # TODO
40
+ end
41
+
42
+ relates "defined? X::Y" do
43
+ # TODO
44
+ end
45
+
46
+ relates "defined? X::Y::Z" do
47
+ # TODO
48
+ end
49
+
50
+ relates "defined? self::A" do
51
+ # TODO
52
+ end
53
+
54
+ relates "defined? self" do
55
+ # TODO
56
+ end
57
+
58
+ relates "defined? true" do
59
+ # TODO
60
+ end
61
+
62
+ relates "defined? false" do
63
+ # TODO
64
+ end
65
+
66
+ relates "defined? nil" do
67
+ # TODO
68
+ end
69
+
70
+ relates "defined? @var" do
71
+ # TODO
72
+ end
73
+
74
+ relates "defined? @@var" do
75
+ # TODO
76
+ end
77
+
78
+ relates "defined? :a" do
79
+ # TODO
80
+ end
81
+
82
+ relates "defined? 'a'" do
83
+ # TODO
84
+ end
85
+
86
+ relates "defined? 0" do
87
+ # TODO
88
+ end
89
+
90
+ relates "defined? yield" do
91
+ # TODO
92
+ end
93
+
94
+ relates "defined? A.m" do
95
+ # TODO
96
+ end
97
+
98
+ relates "defined? ::A.m" do
99
+ # TODO
100
+ end
101
+
102
+ relates "defined? A::B.m" do
103
+ # TODO
104
+ end
105
+
106
+ relates "defined? a.b" do
107
+ # TODO
108
+ end
109
+
110
+ relates <<-ruby do
111
+ a = 1
112
+ defined? a.to_s
113
+ ruby
114
+
115
+ # TODO
116
+ end
117
+ end
data/spec/defn_spec.rb ADDED
@@ -0,0 +1,554 @@
1
+ describe "A Defn node" do
2
+ relates <<-ruby do
3
+ def m
4
+ begin
5
+ end
6
+ end
7
+ ruby
8
+
9
+ parse do
10
+ [:defn, :m, [:args], [:scope, [:block, [:nil]]]]
11
+ end
12
+ end
13
+
14
+ relates <<-ruby do
15
+ def m
16
+ return :a
17
+ ensure
18
+ return :b
19
+ end
20
+ ruby
21
+
22
+ # TODO
23
+ end
24
+
25
+ relates <<-ruby do
26
+ def blah(*args, &block)
27
+ other(42, *args, &block)
28
+ end
29
+ ruby
30
+
31
+ parse do
32
+ [:defn,
33
+ :blah,
34
+ [:args, :"*args", :"&block"],
35
+ [:scope,
36
+ [:block,
37
+ [:call,
38
+ nil,
39
+ :other,
40
+ [:arglist,
41
+ [:lit, 42],
42
+ [:splat, [:lvar, :args]],
43
+ [:block_pass, [:lvar, :block]]]]]]]
44
+ end
45
+ end
46
+
47
+ relates <<-ruby do
48
+ def blah(*args, &block)
49
+ other(*args, &block)
50
+ end
51
+ ruby
52
+
53
+ parse do
54
+ [:defn,
55
+ :blah,
56
+ [:args, :"*args", :"&block"],
57
+ [:scope,
58
+ [:block,
59
+ [:call,
60
+ nil,
61
+ :other,
62
+ [:arglist,
63
+ [:splat, [:lvar, :args]],
64
+ [:block_pass, [:lvar, :block]]]]]]]
65
+ end
66
+ end
67
+
68
+ relates <<-ruby do
69
+ def f
70
+ begin
71
+ b
72
+ rescue
73
+ c
74
+ end
75
+
76
+ d
77
+ end
78
+ ruby
79
+
80
+ parse do
81
+ [:defn,
82
+ :f,
83
+ [:args],
84
+ [:scope,
85
+ [:block,
86
+ [:rescue,
87
+ [:call, nil, :b, [:arglist]],
88
+ [:resbody, [:array], [:call, nil, :c, [:arglist]]]],
89
+ [:call, nil, :d, [:arglist]]]]]
90
+ end
91
+ end
92
+
93
+ relates <<-ruby do
94
+ def f
95
+ a
96
+ begin
97
+ b
98
+ rescue
99
+ c
100
+ end
101
+ end
102
+ ruby
103
+
104
+ parse do
105
+ [:defn,
106
+ :f,
107
+ [:args],
108
+ [:scope,
109
+ [:block,
110
+ [:call, nil, :a, [:arglist]],
111
+ [:rescue,
112
+ [:call, nil, :b, [:arglist]],
113
+ [:resbody, [:array], [:call, nil, :c, [:arglist]]]]]]]
114
+ end
115
+ end
116
+
117
+ relates <<-ruby do
118
+ def f
119
+ a
120
+ begin
121
+ b
122
+ rescue
123
+ c
124
+ end
125
+ d
126
+ end
127
+ ruby
128
+
129
+ parse do
130
+ [:defn,
131
+ :f,
132
+ [:args],
133
+ [:scope,
134
+ [:block,
135
+ [:call, nil, :a, [:arglist]],
136
+ [:rescue,
137
+ [:call, nil, :b, [:arglist]],
138
+ [:resbody, [:array], [:call, nil, :c, [:arglist]]]],
139
+ [:call, nil, :d, [:arglist]]]]]
140
+ end
141
+ end
142
+
143
+ relates <<-ruby do
144
+ def f(&block)
145
+ end
146
+ ruby
147
+
148
+ parse do
149
+ [:defn, :f, [:args, :"&block"], [:scope, [:block, [:nil]]]]
150
+ end
151
+ end
152
+
153
+ relates <<-ruby do
154
+ def f(mand, opt = 42, &block)
155
+ end
156
+ ruby
157
+
158
+ parse do
159
+ [:defn,
160
+ :f,
161
+ [:args, :mand, :opt, :"&block", [:block, [:lasgn, :opt, [:lit, 42]]]],
162
+ [:scope, [:block, [:nil]]]]
163
+ end
164
+ end
165
+
166
+ relates <<-ruby do
167
+ def f(x, a=x.b)
168
+ end
169
+ ruby
170
+
171
+ parse do
172
+ [:defn,
173
+ :f,
174
+ [:args, :x, :a, [:block, [:lasgn, :a, [:call, [:lvar, :x], :b, [:arglist]]]]],
175
+ [:scope, [:block, [:nil]]]]
176
+ end
177
+ end
178
+
179
+ relates <<-ruby do
180
+ def f(mand, &block)
181
+ end
182
+ ruby
183
+
184
+ parse do
185
+ [:defn, :f, [:args, :mand, :"&block"], [:scope, [:block, [:nil]]]]
186
+ end
187
+ end
188
+
189
+ relates <<-ruby do
190
+ def f(mand, opt = 42)
191
+ end
192
+ ruby
193
+
194
+ parse do
195
+ [:defn,
196
+ :f,
197
+ [:args, :mand, :opt, [:block, [:lasgn, :opt, [:lit, 42]]]],
198
+ [:scope, [:block, [:nil]]]]
199
+ end
200
+ end
201
+
202
+ relates <<-ruby do
203
+ def f(mand, opt = 42, *rest, &block)
204
+ end
205
+ ruby
206
+
207
+ parse do
208
+ [:defn,
209
+ :f,
210
+ [:args,
211
+ :mand,
212
+ :opt,
213
+ :"*rest",
214
+ :"&block",
215
+ [:block, [:lasgn, :opt, [:lit, 42]]]],
216
+ [:scope, [:block, [:nil]]]]
217
+ end
218
+ end
219
+
220
+ relates <<-ruby do
221
+ def x(a, b = 42, *)
222
+ end
223
+ ruby
224
+
225
+ parse do
226
+ [:defn,
227
+ :x,
228
+ [:args, :a, :b, :*, [:block, [:lasgn, :b, [:lit, 42]]]],
229
+ [:scope, [:block, [:nil]]]]
230
+ end
231
+ end
232
+
233
+ relates <<-ruby do
234
+ def f(mand, opt = 42, *rest)
235
+ end
236
+ ruby
237
+
238
+ parse do
239
+ [:defn,
240
+ :f,
241
+ [:args, :mand, :opt, :"*rest", [:block, [:lasgn, :opt, [:lit, 42]]]],
242
+ [:scope, [:block, [:nil]]]]
243
+ end
244
+ end
245
+
246
+ relates <<-ruby do
247
+ def empty
248
+ end
249
+ ruby
250
+
251
+ parse do
252
+ [:defn, :empty, [:args], [:scope, [:block, [:nil]]]]
253
+ end
254
+ end
255
+
256
+ relates <<-ruby do
257
+ def f(mand)
258
+ end
259
+ ruby
260
+
261
+ parse do
262
+ [:defn, :f, [:args, :mand], [:scope, [:block, [:nil]]]]
263
+ end
264
+ end
265
+
266
+ relates <<-ruby do
267
+ def f(mand, *rest, &block)
268
+ end
269
+ ruby
270
+
271
+ parse do
272
+ [:defn, :f, [:args, :mand, :"*rest", :"&block"], [:scope, [:block, [:nil]]]]
273
+ end
274
+ end
275
+
276
+ relates <<-ruby do
277
+ def x(a, *args)
278
+ p(a, args)
279
+ end
280
+ ruby
281
+
282
+ parse do
283
+ [:defn,
284
+ :x,
285
+ [:args, :a, :"*args"],
286
+ [:scope, [:block, [:call, nil, :p, [:arglist, [:lvar, :a], [:lvar, :args]]]]]]
287
+ end
288
+ end
289
+
290
+ relates <<-ruby do
291
+ def f(mand, *rest)
292
+ end
293
+ ruby
294
+
295
+ parse do
296
+ [:defn, :f, [:args, :mand, :"*rest"], [:scope, [:block, [:nil]]]]
297
+ end
298
+ end
299
+
300
+ relates <<-ruby do
301
+ def f(opt = 42, &block)
302
+ end
303
+ ruby
304
+
305
+ parse do
306
+ [:defn,
307
+ :f,
308
+ [:args, :opt, :"&block", [:block, [:lasgn, :opt, [:lit, 42]]]],
309
+ [:scope, [:block, [:nil]]]]
310
+ end
311
+ end
312
+
313
+ relates <<-ruby do
314
+ def f(a = 42, b = '1', c=lambda {|n| n })
315
+ end
316
+ ruby
317
+
318
+ parse do
319
+ [:defn,
320
+ :f,
321
+ [:args,
322
+ :a,
323
+ :b,
324
+ :c,
325
+ [:block,
326
+ [:lasgn, :a, [:lit, 42]],
327
+ [:lasgn, :b, [:str, "1"]],
328
+ [:lasgn,
329
+ :c,
330
+ [:iter, [:call, nil, :lambda, [:arglist]], [:lasgn, :n], [:lvar, :n]]]]],
331
+ [:scope, [:block, [:nil]]]]
332
+ end
333
+
334
+ # defn args opt lambda
335
+ end
336
+
337
+ relates <<-ruby do
338
+ def f(opt = 42)
339
+ end
340
+ ruby
341
+
342
+ parse do
343
+ [:defn,
344
+ :f,
345
+ [:args, :opt, [:block, [:lasgn, :opt, [:lit, 42]]]],
346
+ [:scope, [:block, [:nil]]]]
347
+ end
348
+ end
349
+
350
+ relates <<-ruby do
351
+ def f(opt = 42, *rest, &block)
352
+ end
353
+ ruby
354
+
355
+ parse do
356
+ [:defn,
357
+ :f,
358
+ [:args, :opt, :"*rest", :"&block", [:block, [:lasgn, :opt, [:lit, 42]]]],
359
+ [:scope, [:block, [:nil]]]]
360
+ end
361
+ end
362
+
363
+ relates <<-ruby do
364
+ def x(b = 42, *)
365
+ end
366
+ ruby
367
+
368
+ parse do
369
+ [:defn,
370
+ :x,
371
+ [:args, :b, :*, [:block, [:lasgn, :b, [:lit, 42]]]],
372
+ [:scope, [:block, [:nil]]]]
373
+ end
374
+ end
375
+
376
+ relates <<-ruby do
377
+ def f(opt = 42, *rest)
378
+ end
379
+ ruby
380
+
381
+ parse do
382
+ [:defn,
383
+ :f,
384
+ [:args, :opt, :"*rest", [:block, [:lasgn, :opt, [:lit, 42]]]],
385
+ [:scope, [:block, [:nil]]]]
386
+ end
387
+ end
388
+
389
+ relates <<-ruby do
390
+ def |(o)
391
+ end
392
+ ruby
393
+
394
+ parse do
395
+ [:defn, :|, [:args, :o], [:scope, [:block, [:nil]]]]
396
+ end
397
+ end
398
+
399
+ relates <<-ruby do
400
+ def eql?(resource)
401
+ (self.uuid == resource.uuid)
402
+ rescue
403
+ false
404
+ end
405
+ ruby
406
+
407
+ parse do
408
+ [:defn,
409
+ :eql?,
410
+ [:args, :resource],
411
+ [:scope,
412
+ [:block,
413
+ [:rescue,
414
+ [:call,
415
+ [:call, [:self], :uuid, [:arglist]],
416
+ :==,
417
+ [:arglist, [:call, [:lvar, :resource], :uuid, [:arglist]]]],
418
+ [:resbody, [:array], [:false]]]]]]
419
+ end
420
+ end
421
+
422
+ relates <<-ruby do
423
+ def something?
424
+ end
425
+ ruby
426
+
427
+ parse do
428
+ [:defn, :something?, [:args], [:scope, [:block, [:nil]]]]
429
+ end
430
+ end
431
+
432
+ relates <<-ruby do
433
+ def x(*)
434
+ end
435
+ ruby
436
+
437
+ parse do
438
+ [:defn, :x, [:args, :*], [:scope, [:block, [:nil]]]]
439
+ end
440
+ end
441
+
442
+ relates <<-ruby do
443
+ def f(*rest)
444
+ end
445
+ ruby
446
+
447
+ parse do
448
+ [:defn, :f, [:args, :"*rest"], [:scope, [:block, [:nil]]]]
449
+ end
450
+ end
451
+
452
+ relates <<-ruby do
453
+ def x(a, *)
454
+ p(a)
455
+ end
456
+ ruby
457
+
458
+ parse do
459
+ [:defn,
460
+ :x,
461
+ [:args, :a, :*],
462
+ [:scope, [:block, [:call, nil, :p, [:arglist, [:lvar, :a]]]]]]
463
+ end
464
+ end
465
+
466
+ relates <<-ruby do
467
+ def zarray
468
+ a = []
469
+ return a
470
+ end
471
+ ruby
472
+
473
+ parse do
474
+ [:defn,
475
+ :zarray,
476
+ [:args],
477
+ [:scope, [:block, [:lasgn, :a, [:array]], [:return, [:lvar, :a]]]]]
478
+ end
479
+ end
480
+
481
+ relates <<-ruby do
482
+ b = 42
483
+ def a
484
+ c do
485
+ begin
486
+ do_stuff
487
+ rescue RuntimeError => b
488
+ puts(b)
489
+ end
490
+ end
491
+ end
492
+ ruby
493
+
494
+ parse do
495
+ [:block,
496
+ [:lasgn, :b, [:lit, 42]],
497
+ [:defn,
498
+ :a,
499
+ [:args],
500
+ [:scope,
501
+ [:block,
502
+ [:iter,
503
+ [:call, nil, :c, [:arglist]],
504
+ nil,
505
+ [:rescue,
506
+ [:call, nil, :do_stuff, [:arglist]],
507
+ [:resbody,
508
+ [:array, [:const, :RuntimeError], [:lasgn, :b, [:gvar, :$!]]],
509
+ [:call, nil, :puts, [:arglist, [:lvar, :b]]]]]]]]]]
510
+ end
511
+ end
512
+
513
+ relates <<-ruby do
514
+ def x(a=0.0,b=0.0)
515
+ a+b
516
+ end
517
+ ruby
518
+
519
+ parse do
520
+ [:defn,
521
+ :x,
522
+ [:args,
523
+ :a,
524
+ :b,
525
+ [:block, [:lasgn, :a, [:lit, 0.0]], [:lasgn, :b, [:lit, 0.0]]]],
526
+ [:scope, [:block, [:call, [:lvar, :a], :+, [:arglist, [:lvar, :b]]]]]]
527
+ end
528
+ end
529
+
530
+ relates <<-ruby do
531
+ def x(*b)
532
+ a(*b)
533
+ end
534
+ ruby
535
+
536
+ parse do
537
+ [:defn,
538
+ :x,
539
+ [:args, :"*b"],
540
+ [:scope, [:block, [:call, nil, :a, [:arglist, [:splat, [:lvar, :b]]]]]]]
541
+ end
542
+ end
543
+
544
+ relates <<-ruby do
545
+ def meth(b)
546
+ b
547
+ end
548
+ ruby
549
+
550
+ parse do
551
+ [:defn, :meth, [:args, :b], [:scope, [:block, [:lvar, :b]]]]
552
+ end
553
+ end
554
+ end