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
@@ -0,0 +1,359 @@
1
+ describe "A Rescue node" do
2
+ relates "blah rescue nil" do
3
+ parse do
4
+ [:rescue, [:call, nil, :blah, [:arglist]], [:resbody, [:array], [:nil]]]
5
+ end
6
+ end
7
+
8
+ relates <<-ruby do
9
+ begin
10
+ blah
11
+ rescue
12
+ end
13
+ ruby
14
+
15
+ parse do
16
+ [:rescue, [:call, nil, :blah, [:arglist]], [:resbody, [:array], nil]]
17
+ end
18
+ end
19
+
20
+ relates <<-ruby do
21
+ begin
22
+ a
23
+ rescue A
24
+ b
25
+ rescue B
26
+ c
27
+ rescue C
28
+ d
29
+ end
30
+ ruby
31
+
32
+ parse do
33
+ [:rescue,
34
+ [:call, nil, :a, [:arglist]],
35
+ [:resbody, [:array, [:const, :A]], [:call, nil, :b, [:arglist]]],
36
+ [:resbody, [:array, [:const, :B]], [:call, nil, :c, [:arglist]]],
37
+ [:resbody, [:array, [:const, :C]], [:call, nil, :d, [:arglist]]]]
38
+ end
39
+ end
40
+
41
+ relates <<-ruby do
42
+ begin
43
+ a
44
+ rescue => @e
45
+ c
46
+ d
47
+ end
48
+ ruby
49
+
50
+ parse do
51
+ [:rescue,
52
+ [:call, nil, :a, [:arglist]],
53
+ [:resbody,
54
+ [:array, [:iasgn, :@e, [:gvar, :$!]]],
55
+ [:block, [:call, nil, :c, [:arglist]], [:call, nil, :d, [:arglist]]]]]
56
+ end
57
+ end
58
+
59
+ relates <<-ruby do
60
+ begin
61
+ a
62
+ rescue => e
63
+ c
64
+ d
65
+ end
66
+ ruby
67
+
68
+ parse do
69
+ [:rescue,
70
+ [:call, nil, :a, [:arglist]],
71
+ [:resbody,
72
+ [:array, [:lasgn, :e, [:gvar, :$!]]],
73
+ [:block, [:call, nil, :c, [:arglist]], [:call, nil, :d, [:arglist]]]]]
74
+ end
75
+ end
76
+
77
+ relates <<-ruby do
78
+ begin
79
+ a
80
+ rescue => mes
81
+ # do nothing
82
+ end
83
+
84
+ begin
85
+ b
86
+ rescue => mes
87
+ # do nothing
88
+ end
89
+ ruby
90
+
91
+ parse do
92
+ [:block,
93
+ [:rescue,
94
+ [:call, nil, :a, [:arglist]],
95
+ [:resbody, [:array, [:lasgn, :mes, [:gvar, :$!]]], nil]],
96
+ [:rescue,
97
+ [:call, nil, :b, [:arglist]],
98
+ [:resbody, [:array, [:lasgn, :mes, [:gvar, :$!]]], nil]]]
99
+ end
100
+ end
101
+
102
+ relates <<-ruby do
103
+ begin
104
+ blah
105
+ rescue RuntimeError => r
106
+ end
107
+ ruby
108
+
109
+ parse do
110
+ [:rescue,
111
+ [:call, nil, :blah, [:arglist]],
112
+ [:resbody,
113
+ [:array, [:const, :RuntimeError], [:lasgn, :r, [:gvar, :$!]]],
114
+ nil]]
115
+ end
116
+ end
117
+
118
+ relates <<-ruby do
119
+ begin
120
+ 1
121
+ rescue => @e
122
+ end
123
+ ruby
124
+
125
+ parse do
126
+ [:rescue, [:lit, 1], [:resbody, [:array, [:iasgn, :@e, [:gvar, :$!]]], nil]]
127
+ end
128
+ end
129
+
130
+ relates <<-ruby do
131
+ begin
132
+ 1
133
+ rescue
134
+ var = 2
135
+ end
136
+ ruby
137
+
138
+ parse do
139
+ [:rescue, [:lit, 1], [:resbody, [:array], [:lasgn, :var, [:lit, 2]]]]
140
+ end
141
+ end
142
+
143
+ relates <<-ruby do
144
+ begin
145
+ 1
146
+ rescue => e
147
+ end
148
+ ruby
149
+
150
+ parse do
151
+ [:rescue, [:lit, 1], [:resbody, [:array, [:lasgn, :e, [:gvar, :$!]]], nil]]
152
+ end
153
+ end
154
+
155
+ relates <<-ruby do
156
+ begin
157
+ 1
158
+ rescue
159
+ a.b = nil
160
+ end
161
+ ruby
162
+
163
+ parse do
164
+ [:rescue,
165
+ [:lit, 1],
166
+ [:resbody,
167
+ [:array],
168
+ [:attrasgn, [:call, nil, :a, [:arglist]], :b=, [:arglist, [:nil]]]]]
169
+ end
170
+ end
171
+
172
+ relates <<-ruby do
173
+ begin
174
+ 1
175
+ rescue => e
176
+ var = 2
177
+ end
178
+ ruby
179
+
180
+ parse do
181
+ [:rescue,
182
+ [:lit, 1],
183
+ [:resbody, [:array, [:lasgn, :e, [:gvar, :$!]]], [:lasgn, :var, [:lit, 2]]]]
184
+ end
185
+ end
186
+
187
+ relates <<-ruby do
188
+ begin
189
+ 12
190
+ rescue String
191
+ 13
192
+ else
193
+ 14
194
+ end
195
+ ruby
196
+
197
+ parse do
198
+ [:rescue,
199
+ [:lit, 12],
200
+ [:resbody, [:array, [:const, :String]], [:lit, 13]],
201
+ [:lit, 14]]
202
+ end
203
+ end
204
+
205
+ relates <<-ruby do
206
+ begin
207
+ 12
208
+ rescue *blah
209
+ 13
210
+ end
211
+ ruby
212
+
213
+ parse do
214
+ [:rescue,
215
+ [:lit, 12],
216
+ [:resbody, [:splat, [:call, nil, :blah, [:arglist]]], [:lit, 13]]]
217
+ end
218
+ end
219
+
220
+ relates <<-ruby do
221
+ begin
222
+ 12
223
+ rescue String, *blah
224
+ 13
225
+ end
226
+ ruby
227
+
228
+ parse do
229
+ [:rescue,
230
+ [:lit, 12],
231
+ [:resbody,
232
+ [:array, [:const, :String], [:splat, [:call, nil, :blah, [:arglist]]]],
233
+ [:lit, 13]]]
234
+ end
235
+ end
236
+
237
+ relates <<-ruby do
238
+ begin
239
+ 12
240
+ rescue *blah => e
241
+ 13
242
+ end
243
+ ruby
244
+
245
+ parse do
246
+ [:rescue,
247
+ [:lit, 12],
248
+ [:resbody,
249
+ [:splat, [:call, nil, :blah, [:arglist]], [:lasgn, :e, [:gvar, :$!]]],
250
+ [:lit, 13]]]
251
+ end
252
+ end
253
+
254
+ relates <<-ruby do
255
+ begin
256
+ 12
257
+ rescue String, *blah => e
258
+ 13
259
+ end
260
+ ruby
261
+
262
+ parse do
263
+ [:rescue,
264
+ [:lit, 12],
265
+ [:resbody,
266
+ [:array,
267
+ [:const, :String],
268
+ [:splat, [:call, nil, :blah, [:arglist]]],
269
+ [:lasgn, :e, [:gvar, :$!]]],
270
+ [:lit, 13]]]
271
+ end
272
+ end
273
+
274
+ relates <<-ruby do
275
+ begin
276
+ 12
277
+ rescue String
278
+ return nil
279
+ end
280
+ ruby
281
+
282
+ parse do
283
+ [:rescue,
284
+ [:lit, 12],
285
+ [:resbody, [:array, [:const, :String]], [:return, [:nil]]]]
286
+ end
287
+ end
288
+
289
+ relates <<-ruby do
290
+ begin
291
+ 1
292
+ rescue
293
+ begin
294
+ 2
295
+ rescue
296
+ return 3
297
+ end
298
+ end
299
+ ruby
300
+
301
+ parse do
302
+ [:rescue,
303
+ [:lit, 1],
304
+ [:resbody,
305
+ [:array],
306
+ [:rescue, [:lit, 2], [:resbody, [:array], [:return, [:lit, 3]]]]]]
307
+ end
308
+ end
309
+
310
+ relates <<-ruby do
311
+ begin
312
+ 1
313
+ rescue
314
+ def x
315
+ return 2
316
+ end
317
+ x
318
+ end
319
+ ruby
320
+
321
+ parse do
322
+ [:rescue,
323
+ [:lit, 1],
324
+ [:resbody,
325
+ [:array],
326
+ [:block,
327
+ [:defn, :x, [:args], [:scope, [:block, [:return, [:lit, 2]]]]],
328
+ [:call, nil, :x, [:arglist]]]]]
329
+ end
330
+ end
331
+
332
+ relates <<-ruby do
333
+ begin
334
+ while 1
335
+ 2
336
+ break :brk
337
+ end
338
+ rescue
339
+ 3
340
+ end
341
+ ruby
342
+
343
+ # TODO
344
+ end
345
+
346
+ relates <<-ruby do
347
+ begin
348
+ 1
349
+ rescue
350
+ while 2
351
+ 3
352
+ break :brk
353
+ end
354
+ end
355
+ ruby
356
+
357
+ # TODO
358
+ end
359
+ end
@@ -0,0 +1,57 @@
1
+ describe "A Return node" do
2
+ relates "return" do
3
+ parse do
4
+ [:return]
5
+ end
6
+ end
7
+
8
+ relates "return 1" do
9
+ parse do
10
+ [:return, [:lit, 1]]
11
+ end
12
+ end
13
+
14
+ relates "return *1" do
15
+ parse do
16
+ [:return, [:svalue, [:splat, [:lit, 1]]]]
17
+ end
18
+ end
19
+
20
+ relates <<-ruby do
21
+ x = 1, 2
22
+ return *x
23
+ ruby
24
+
25
+ parse do
26
+ [:block,
27
+ [:lasgn, :x, [:svalue, [:array, [:lit, 1], [:lit, 2]]]],
28
+ [:return, [:svalue, [:splat, [:lvar, :x]]]]]
29
+ end
30
+ end
31
+
32
+ relates "return 1, 2, 3" do
33
+ parse do
34
+ [:return, [:array, [:lit, 1], [:lit, 2], [:lit, 3]]]
35
+ end
36
+ end
37
+
38
+ relates "return 1, 2, *c" do
39
+ parse do
40
+ [:return,
41
+ [:array,
42
+ [:lit, 1], [:lit, 2], [:splat, [:call, nil, :c, [:arglist]]]]]
43
+ end
44
+ end
45
+
46
+ relates "return [*[1]]" do
47
+ parse do
48
+ [:return, [:array, [:splat, [:array, [:lit, 1]]]]]
49
+ end
50
+ end
51
+
52
+ relates "return *[1]" do
53
+ parse do
54
+ [:return, [:svalue, [:splat, [:array, [:lit, 1]]]]]
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,55 @@
1
+ describe "An Sclass node" do
2
+ relates <<-ruby do
3
+ class << self
4
+ 42
5
+ end
6
+ ruby
7
+
8
+ parse do
9
+ [:sclass, [:self], [:scope, [:lit, 42]]]
10
+ end
11
+ end
12
+
13
+ relates <<-ruby do
14
+ class A
15
+ class << self
16
+ a
17
+ end
18
+ class B
19
+ end
20
+ end
21
+ ruby
22
+
23
+ parse do
24
+ [:class,
25
+ :A,
26
+ nil,
27
+ [:scope,
28
+ [:block,
29
+ [:sclass, [:self], [:scope, [:call, nil, :a, [:arglist]]]],
30
+ [:class, :B, nil, [:scope]]]]]
31
+ end
32
+ end
33
+
34
+ relates <<-ruby do
35
+ x = "a"
36
+ class << x
37
+ end
38
+ ruby
39
+
40
+ parse do
41
+ [:block,
42
+ [:lasgn, :x, [:str, "a"]],
43
+ [:sclass, [:lvar, :x], [:scope]]]
44
+ end
45
+ end
46
+
47
+ relates <<-ruby do
48
+ x = "a"
49
+ m do
50
+ class << x
51
+ end
52
+ end
53
+ ruby
54
+ end
55
+ end