rubinius-compiler 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -0
  3. data/lib/rubinius/compiler/compiled_file.rb +32 -32
  4. data/lib/rubinius/compiler/version.rb +2 -2
  5. data/rubinius-compiler.gemspec +6 -0
  6. data/spec/alias_spec.rb +39 -0
  7. data/spec/and_spec.rb +44 -0
  8. data/spec/array_spec.rb +110 -0
  9. data/spec/attrasgn_spec.rb +186 -0
  10. data/spec/back_ref_spec.rb +11 -0
  11. data/spec/call_spec.rb +580 -0
  12. data/spec/case_spec.rb +576 -0
  13. data/spec/cdecl_spec.rb +70 -0
  14. data/spec/class_spec.rb +120 -0
  15. data/spec/colon2_spec.rb +8 -0
  16. data/spec/colon3_spec.rb +8 -0
  17. data/spec/const_spec.rb +7 -0
  18. data/spec/custom/guards/profiler.rb +18 -0
  19. data/spec/custom/helpers/generator.rb +828 -0
  20. data/spec/custom/matchers/compile_as.rb +46 -0
  21. data/spec/custom/mspec.rb +15 -0
  22. data/spec/custom/runner/actions/debug.rb +10 -0
  23. data/spec/custom/runner/actions/gcstats.rb +17 -0
  24. data/spec/custom/runner/actions/memory.rb +11 -0
  25. data/spec/custom/runner/actions/parser.rb +14 -0
  26. data/spec/custom/runner/actions/profiler.rb +19 -0
  27. data/spec/custom/runner/relates.rb +86 -0
  28. data/spec/custom/utils/options.rb +40 -0
  29. data/spec/custom/utils/script.rb +50 -0
  30. data/spec/cvar_spec.rb +39 -0
  31. data/spec/cvasgn_spec.rb +33 -0
  32. data/spec/cvdecl_spec.rb +17 -0
  33. data/spec/defined_spec.rb +616 -0
  34. data/spec/defn_spec.rb +732 -0
  35. data/spec/defs_spec.rb +113 -0
  36. data/spec/dot2_spec.rb +16 -0
  37. data/spec/dot3_spec.rb +17 -0
  38. data/spec/dregx_spec.rb +160 -0
  39. data/spec/dstr_spec.rb +424 -0
  40. data/spec/dsym_spec.rb +18 -0
  41. data/spec/dxstr_spec.rb +24 -0
  42. data/spec/ensure_spec.rb +196 -0
  43. data/spec/false_spec.rb +7 -0
  44. data/spec/flip2_spec.rb +21 -0
  45. data/spec/flip3_spec.rb +12 -0
  46. data/spec/for_spec.rb +228 -0
  47. data/spec/gasgn_spec.rb +15 -0
  48. data/spec/generator/encode_spec.rb +34 -0
  49. data/spec/gvar_spec.rb +37 -0
  50. data/spec/hash_spec.rb +108 -0
  51. data/spec/iasgn_spec.rb +26 -0
  52. data/spec/if_spec.rb +415 -0
  53. data/spec/iter_spec.rb +1011 -0
  54. data/spec/lasgn_spec.rb +561 -0
  55. data/spec/lit_spec.rb +61 -0
  56. data/spec/masgn_spec.rb +1558 -0
  57. data/spec/match2_spec.rb +42 -0
  58. data/spec/match3_spec.rb +54 -0
  59. data/spec/match_spec.rb +29 -0
  60. data/spec/module_spec.rb +73 -0
  61. data/spec/nil_spec.rb +7 -0
  62. data/spec/not_spec.rb +47 -0
  63. data/spec/nth_ref_spec.rb +7 -0
  64. data/spec/op_asgn_spec.rb +563 -0
  65. data/spec/or_spec.rb +126 -0
  66. data/spec/postexe_spec.rb +11 -0
  67. data/spec/preexe_spec.rb +21 -0
  68. data/spec/regex_spec.rb +54 -0
  69. data/spec/rescue_spec.rb +763 -0
  70. data/spec/return_spec.rb +152 -0
  71. data/spec/sclass_spec.rb +138 -0
  72. data/spec/spec_helper.rb +12 -0
  73. data/spec/str_spec.rb +118 -0
  74. data/spec/super_spec.rb +170 -0
  75. data/spec/transforms/assembly_spec.rb +195 -0
  76. data/spec/transforms/block_given_spec.rb +75 -0
  77. data/spec/transforms/fast_coerce_spec.rb +112 -0
  78. data/spec/transforms/fast_new_spec.rb +255 -0
  79. data/spec/transforms/invoke_primitive_spec.rb +14 -0
  80. data/spec/transforms/kernel_methods_spec.rb +29 -0
  81. data/spec/transforms/primitive_spec.rb +33 -0
  82. data/spec/transforms/privately_spec.rb +24 -0
  83. data/spec/true_spec.rb +7 -0
  84. data/spec/undef_spec.rb +133 -0
  85. data/spec/until_spec.rb +254 -0
  86. data/spec/valias_spec.rb +11 -0
  87. data/spec/while_spec.rb +494 -0
  88. data/spec/xstr_spec.rb +10 -0
  89. data/spec/yield_spec.rb +92 -0
  90. data/spec/zsuper_spec.rb +63 -0
  91. metadata +258 -3
@@ -0,0 +1,561 @@
1
+ describe "An Lasgn node" do
2
+ relates "a = 1" do
3
+ compile do |g|
4
+ g.push 1
5
+ g.set_local 0
6
+ end
7
+ end
8
+
9
+ relates "a = b, c, *d" do
10
+ compile do |g|
11
+ g.push :self
12
+ g.send :b, 0, true
13
+ g.push :self
14
+ g.send :c, 0, true
15
+ g.make_array 2
16
+ g.push :self
17
+ g.send :d, 0, true
18
+ g.cast_array
19
+ g.send :+, 1
20
+ g.set_local 0
21
+ end
22
+ end
23
+
24
+ relates "a = [b, *c]" do
25
+ compile do |g|
26
+ g.push :self
27
+ g.send :b, 0, true
28
+ g.make_array 1
29
+ g.push :self
30
+ g.send :c, 0, true
31
+ g.cast_array
32
+ g.send :+, 1
33
+ g.set_local 0
34
+ end
35
+ end
36
+
37
+ relates <<-ruby do
38
+ x = (y = 1
39
+ (y + 2))
40
+ ruby
41
+
42
+ compile do |g|
43
+ g.push 1
44
+ g.set_local 1
45
+ g.pop
46
+ g.push_local 1
47
+ g.push 2
48
+ g.send :+, 1, false
49
+ g.set_local 0
50
+ end
51
+ end
52
+
53
+ relates <<-ruby do
54
+ a = []
55
+ a [42]
56
+ ruby
57
+
58
+ # call index space
59
+ end
60
+
61
+ relates 'var = ["foo", "bar"]' do
62
+ compile do |g|
63
+ g.push_literal "foo"
64
+ g.string_dup
65
+ g.push_literal "bar"
66
+ g.string_dup
67
+ g.make_array 2
68
+ g.set_local 0
69
+ end
70
+ end
71
+
72
+ relates "c = (2 + 3)" do
73
+ compile do |g|
74
+ g.push 2
75
+ g.push 3
76
+ g.send :+, 1, false
77
+ g.set_local 0
78
+ end
79
+ end
80
+
81
+ ruby_version_is ""..."1.9" do
82
+ relates "a = *[1]" do
83
+ compile do |g|
84
+ g.splatted_array
85
+ g.set_local 0
86
+ end
87
+ end
88
+
89
+ relates "a = *b" do
90
+ compile do |g|
91
+ t = g.new_label
92
+
93
+ g.push :self
94
+ g.send :b, 0, true
95
+ g.cast_array
96
+ g.dup
97
+
98
+ g.send :size, 0
99
+ g.push 1
100
+ g.send :>, 1
101
+ g.git t
102
+
103
+ g.push 0
104
+ g.send :at, 1
105
+ t.set!
106
+ g.set_local 0
107
+ end
108
+ end
109
+ end
110
+
111
+ ruby_version_is "1.9" do
112
+ relates "a = *[1]" do
113
+ compile do |g|
114
+ g.push 1
115
+ g.make_array 1
116
+ g.set_local 0
117
+ end
118
+ end
119
+
120
+ relates "a = *b" do
121
+ compile do |g|
122
+ g.push :self
123
+ g.send :b, 0, true
124
+ g.cast_array
125
+ g.set_local 0
126
+ end
127
+ end
128
+ end
129
+
130
+ relates <<-ruby do
131
+ a = if c
132
+ begin
133
+ b
134
+ rescue
135
+ nil
136
+ end
137
+ end
138
+ a
139
+ ruby
140
+
141
+ compile do |g|
142
+ bottom = g.new_label
143
+ f = g.new_label
144
+
145
+ g.push :self
146
+ g.send :c, 0, true
147
+ g.gif f
148
+
149
+ for_rescue do |rb|
150
+ rb.body do
151
+ g.push :self
152
+ g.send :b, 0, true
153
+ end
154
+
155
+ rb.condition :StandardError, true do
156
+ g.push :nil
157
+ end
158
+ end
159
+
160
+ g.goto bottom
161
+
162
+ f.set!
163
+ g.push :nil
164
+
165
+ bottom.set!
166
+ g.set_local 0
167
+ g.pop
168
+ g.push_local 0
169
+ end
170
+ end
171
+
172
+ relates "x = [*[1]]" do
173
+ compile do |g|
174
+ g.push 1
175
+ g.make_array 1
176
+ g.set_local 0
177
+ end
178
+ end
179
+
180
+ relates "a = []" do
181
+ compile do |g|
182
+ g.make_array 0
183
+ g.set_local 0
184
+ end
185
+ end
186
+
187
+ relates <<-ruby do
188
+ a = 12
189
+ a
190
+ ruby
191
+
192
+ compile do |g|
193
+ g.push 12
194
+ g.set_local 0
195
+ g.pop
196
+ g.push_local 0
197
+ end
198
+ end
199
+
200
+ relates <<-ruby do
201
+ name
202
+ name = 3
203
+ name
204
+ ruby
205
+
206
+ # TODO
207
+ end
208
+
209
+ relates "a=12; b=13; true" do
210
+ compile do |g|
211
+ g.push 12
212
+ g.set_local 0
213
+ g.pop
214
+ g.push 13
215
+ g.set_local 1
216
+ g.pop
217
+ g.push :true
218
+ end
219
+ end
220
+
221
+ relates <<-ruby do
222
+ def f
223
+ a = 1
224
+ end
225
+ ruby
226
+
227
+ compile do |g|
228
+ in_method :f do |d|
229
+ d.push 1
230
+ d.set_local 0
231
+ end
232
+ end
233
+ end
234
+
235
+ relates <<-ruby do
236
+ def f(a)
237
+ a = 1
238
+ end
239
+ ruby
240
+
241
+ compile do |g|
242
+ in_method :f do |d|
243
+ d.push 1
244
+ d.set_local 0
245
+ end
246
+ end
247
+ end
248
+
249
+ relates <<-ruby do
250
+ def f
251
+ b { a = 1 }
252
+ end
253
+ ruby
254
+
255
+ compile do |g|
256
+ in_method :f do |d|
257
+ d.push :self
258
+
259
+ d.in_block_send :b, :none do |e|
260
+ e.push 1
261
+ e.set_local 0
262
+ end
263
+ end
264
+ end
265
+ end
266
+
267
+ relates <<-ruby do
268
+ def f(a)
269
+ b { a = 2 }
270
+ end
271
+ ruby
272
+
273
+ compile do |g|
274
+ in_method :f do |d|
275
+ d.push :self
276
+
277
+ d.in_block_send :b, :none do |e|
278
+ e.push 2
279
+ e.set_local_depth 1, 0
280
+ end
281
+ end
282
+ end
283
+ end
284
+
285
+ relates <<-ruby do
286
+ def f
287
+ a = 1
288
+ b { a = 2 }
289
+ end
290
+ ruby
291
+
292
+ compile do |g|
293
+ in_method :f do |d|
294
+ d.push 1
295
+ d.set_local 0
296
+ d.pop
297
+
298
+ d.push :self
299
+
300
+ d.in_block_send :b, :none do |e|
301
+ e.push 2
302
+ e.set_local_depth 1, 0
303
+ end
304
+ end
305
+ end
306
+ end
307
+
308
+ relates <<-ruby do
309
+ def f
310
+ a
311
+ b { a = 1 }
312
+ end
313
+ ruby
314
+
315
+ compile do |g|
316
+ in_method :f do |d|
317
+ d.push :self
318
+ d.send :a, 0, true
319
+ d.pop
320
+
321
+ d.push :self
322
+
323
+ d.in_block_send :b, :none do |e|
324
+ e.push 1
325
+ e.set_local 0
326
+ end
327
+ end
328
+ end
329
+ end
330
+
331
+ relates <<-ruby do
332
+ def f
333
+ b { a = 1 }
334
+ a
335
+ end
336
+ ruby
337
+
338
+ compile do |g|
339
+ in_method :f do |d|
340
+ d.push :self
341
+
342
+ d.in_block_send :b, :none do |e|
343
+ e.push 1
344
+ e.set_local 0
345
+ end
346
+
347
+ d.pop
348
+ d.push :self
349
+ d.send :a, 0, true
350
+ end
351
+ end
352
+ end
353
+
354
+ relates <<-ruby do
355
+ def f
356
+ a = 1
357
+ b { a = 2 }
358
+ a
359
+ end
360
+ ruby
361
+
362
+ compile do |g|
363
+ in_method :f do |d|
364
+ d.push 1
365
+ d.set_local 0
366
+ d.pop
367
+
368
+ d.push :self
369
+
370
+ d.in_block_send :b, :none do |e|
371
+ e.push 2
372
+ e.set_local_depth 1, 0
373
+ end
374
+
375
+ d.pop
376
+ d.push_local 0
377
+ end
378
+ end
379
+ end
380
+
381
+ relates <<-ruby do
382
+ class F
383
+ a = 1
384
+ end
385
+ ruby
386
+
387
+ compile do |g|
388
+ in_class :F do |d|
389
+ d.push 1
390
+ d.set_local 0
391
+ end
392
+ end
393
+ end
394
+
395
+ relates <<-ruby do
396
+ a = Object
397
+ class a::F
398
+ b = 1
399
+ end
400
+ ruby
401
+
402
+ compile do |g|
403
+ g.push_const :Object
404
+ g.set_local 0
405
+ g.pop
406
+
407
+ g.push_rubinius
408
+ g.push_literal :F
409
+ g.push :nil
410
+ g.push_local 0
411
+ g.send :open_class_under, 3
412
+
413
+ d = new_generator(g, :F)
414
+ g.create_block d
415
+
416
+ d.push_self
417
+ d.add_scope
418
+
419
+ d.push 1
420
+ d.set_local 0
421
+ d.ret
422
+
423
+ g.swap
424
+ g.push_scope
425
+ g.push_true
426
+ g.send :call_under, 3
427
+ end
428
+ end
429
+
430
+ relates <<-ruby do
431
+ a = Object
432
+ class F < a
433
+ b = 1
434
+ end
435
+ ruby
436
+
437
+ compile do |g|
438
+ g.push_const :Object
439
+ g.set_local 0
440
+ g.pop
441
+
442
+ g.push_rubinius
443
+ g.push_literal :F
444
+ g.push_local 0
445
+ g.push_scope
446
+ g.send :open_class, 3
447
+
448
+ d = new_generator(g, :F)
449
+ g.create_block d
450
+
451
+ d.push_self
452
+ d.add_scope
453
+
454
+ d.push 1
455
+ d.set_local 0
456
+
457
+ d.ret
458
+
459
+ g.swap
460
+ g.push_scope
461
+ g.push_true
462
+ g.send :call_under, 3
463
+ end
464
+ end
465
+
466
+ relates <<-ruby do
467
+ class F
468
+ a = 1
469
+ def f
470
+ a = 1
471
+ end
472
+ end
473
+ ruby
474
+
475
+ compile do |g|
476
+ in_class :F do |d|
477
+ d.push 1
478
+ d.set_local 0
479
+ d.pop
480
+
481
+ d.in_method :f do |e|
482
+ e.push 1
483
+ e.set_local 0
484
+ end
485
+ end
486
+ end
487
+ end
488
+
489
+ relates <<-ruby do
490
+ module M
491
+ a = 1
492
+ end
493
+ ruby
494
+
495
+ compile do |g|
496
+ in_module :M do |d|
497
+ d.push 1
498
+ d.set_local 0
499
+ end
500
+ end
501
+ end
502
+
503
+ relates <<-ruby do
504
+ module M
505
+ a = 1
506
+ def f
507
+ a = 1
508
+ end
509
+ end
510
+ ruby
511
+
512
+ compile do |g|
513
+ in_module :M do |d|
514
+ d.push 1
515
+ d.set_local 0
516
+ d.pop
517
+
518
+ d.in_method :f do |e|
519
+ e.push 1
520
+ e.set_local 0
521
+ end
522
+ end
523
+ end
524
+ end
525
+
526
+ relates <<-ruby do
527
+ a = Object
528
+ module a::M
529
+ b = 1
530
+ end
531
+ ruby
532
+
533
+ compile do |g|
534
+ g.push_const :Object
535
+ g.set_local 0
536
+ g.pop
537
+
538
+ g.push_rubinius
539
+ g.push_literal :M
540
+ g.push_local 0
541
+ g.send :open_module_under, 2
542
+
543
+
544
+ d = new_generator(g, :F)
545
+ g.create_block d
546
+
547
+ d.push_self
548
+ d.add_scope
549
+
550
+ d.push 1
551
+ d.set_local 0
552
+
553
+ d.ret
554
+
555
+ g.swap
556
+ g.push_scope
557
+ g.push_true
558
+ g.send :call_under, 3
559
+ end
560
+ end
561
+ end