rubinius-melbourne 2.0.1.0 → 2.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -9
- data/Gemfile +0 -4
- data/Rakefile +26 -19
- data/ext/rubinius/melbourne/extconf.rb +4 -3
- data/ext/rubinius/melbourne/grammar.cpp +2 -2
- data/ext/rubinius/melbourne/grammar.y +2 -2
- data/ext/rubinius/melbourne/melbourne.cpp +4 -5
- data/lib/rubinius/melbourne/version.rb +2 -2
- data/lib/rubinius/melbourne.rb +1 -21
- data/rubinius-melbourne.gemspec +6 -3
- data/spec/alias_spec.rb +13 -18
- data/spec/and_spec.rb +6 -12
- data/spec/array_spec.rb +28 -54
- data/spec/attrasgn_spec.rb +60 -85
- data/spec/back_ref_spec.rb +6 -8
- data/spec/call_spec.rb +137 -225
- data/spec/case_spec.rb +94 -112
- data/spec/cdecl_spec.rb +16 -28
- data/spec/class_spec.rb +28 -40
- data/spec/colon2_spec.rb +2 -4
- data/spec/colon3_spec.rb +2 -4
- data/spec/const_spec.rb +2 -4
- data/spec/custom/runner/relates.rb +4 -0
- data/spec/cvar_spec.rb +6 -12
- data/spec/cvasgn_spec.rb +20 -15
- data/spec/defined_spec.rb +57 -55
- data/spec/defn_spec.rb +218 -280
- data/spec/defs_spec.rb +30 -38
- data/spec/dot2_spec.rb +2 -4
- data/spec/dot3_spec.rb +2 -4
- data/spec/dregx_spec.rb +20 -34
- data/spec/dstr_spec.rb +87 -111
- data/spec/dsym_spec.rb +5 -7
- data/spec/dxstr_spec.rb +2 -4
- data/spec/ensure_spec.rb +32 -40
- data/spec/false_spec.rb +2 -4
- data/spec/flip2_spec.rb +22 -26
- data/spec/flip3_spec.rb +15 -17
- data/spec/for_spec.rb +25 -23
- data/spec/gasgn_spec.rb +4 -8
- data/spec/gvar_spec.rb +8 -16
- data/spec/hash_spec.rb +14 -18
- data/spec/iasgn_spec.rb +8 -14
- data/spec/if_spec.rb +50 -80
- data/spec/iter_spec.rb +328 -402
- data/spec/lasgn_spec.rb +143 -200
- data/spec/lit_spec.rb +20 -40
- data/spec/masgn_spec.rb +278 -309
- data/spec/match2_spec.rb +6 -10
- data/spec/match3_spec.rb +9 -13
- data/spec/match_spec.rb +2 -4
- data/spec/module_spec.rb +12 -16
- data/spec/nil_spec.rb +2 -4
- data/spec/not_spec.rb +6 -8
- data/spec/nth_ref_spec.rb +2 -4
- data/spec/op_asgn_spec.rb +118 -158
- data/spec/or_spec.rb +18 -24
- data/spec/postexe_spec.rb +2 -4
- data/spec/regex_spec.rb +11 -19
- data/spec/rescue_spec.rb +135 -143
- data/spec/return_spec.rb +19 -36
- data/spec/sclass_spec.rb +26 -25
- data/spec/spec_helper.rb +9 -0
- data/spec/str_spec.rb +25 -43
- data/spec/super_spec.rb +31 -49
- data/spec/true_spec.rb +2 -4
- data/spec/undef_spec.rb +38 -53
- data/spec/until_spec.rb +13 -105
- data/spec/valias_spec.rb +2 -4
- data/spec/while_spec.rb +35 -117
- data/spec/xstr_spec.rb +2 -4
- data/spec/yield_spec.rb +22 -42
- data/spec/zsuper_spec.rb +8 -16
- metadata +64 -22
- data/spec/cvdecl_spec.rb +0 -12
data/spec/case_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe "A Case node" do
|
2
|
-
|
2
|
+
parse <<-ruby do
|
3
3
|
var = 2
|
4
4
|
result = ""
|
5
5
|
case var
|
@@ -25,32 +25,30 @@ describe "A Case node" do
|
|
25
25
|
end
|
26
26
|
ruby
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
nil]]
|
50
|
-
end
|
28
|
+
[:block,
|
29
|
+
[:lasgn, :var, [:lit, 2]],
|
30
|
+
[:lasgn, :result, [:str, ""]],
|
31
|
+
[:case,
|
32
|
+
[:lvar, :var],
|
33
|
+
[:when,
|
34
|
+
[:array, [:lit, 1]],
|
35
|
+
[:block,
|
36
|
+
[:call, nil, :puts, [:arglist, [:str, "something"]]],
|
37
|
+
[:lasgn, :result, [:str, "red"]]]],
|
38
|
+
[:when,
|
39
|
+
[:array, [:lit, 2], [:lit, 3]],
|
40
|
+
[:lasgn, :result, [:str, "yellow"]]],
|
41
|
+
[:when, [:array, [:lit, 4]], [:nil]],
|
42
|
+
[:lasgn, :result, [:str, "green"]]],
|
43
|
+
[:case,
|
44
|
+
[:lvar, :result],
|
45
|
+
[:when, [:array, [:str, "red"]], [:lasgn, :var, [:lit, 1]]],
|
46
|
+
[:when, [:array, [:str, "yellow"]], [:lasgn, :var, [:lit, 2]]],
|
47
|
+
[:when, [:array, [:str, "green"]], [:lasgn, :var, [:lit, 3]]],
|
48
|
+
[:nil]]]
|
51
49
|
end
|
52
50
|
|
53
|
-
|
51
|
+
parse <<-ruby do
|
54
52
|
case a
|
55
53
|
when b then
|
56
54
|
case
|
@@ -64,25 +62,23 @@ describe "A Case node" do
|
|
64
62
|
end
|
65
63
|
ruby
|
66
64
|
|
67
|
-
|
65
|
+
[:case,
|
66
|
+
[:call, nil, :a, [:arglist]],
|
67
|
+
[:when,
|
68
|
+
[:array, [:call, nil, :b, [:arglist]]],
|
68
69
|
[:case,
|
69
|
-
|
70
|
+
nil,
|
70
71
|
[:when,
|
71
|
-
[:array,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
[:call, nil, :e, [:arglist]]]],
|
79
|
-
[:call, nil, :f, [:arglist]]],
|
80
|
-
nil]],
|
81
|
-
nil]
|
82
|
-
end
|
72
|
+
[:array,
|
73
|
+
[:and,
|
74
|
+
[:call, nil, :d, [:arglist]],
|
75
|
+
[:call, nil, :e, [:arglist]]]],
|
76
|
+
[:call, nil, :f, [:arglist]]],
|
77
|
+
[:nil]]],
|
78
|
+
[:nil]]
|
83
79
|
end
|
84
80
|
|
85
|
-
|
81
|
+
parse <<-ruby do
|
86
82
|
var1 = 1
|
87
83
|
var2 = 2
|
88
84
|
result = nil
|
@@ -110,32 +106,30 @@ describe "A Case node" do
|
|
110
106
|
end
|
111
107
|
ruby
|
112
108
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
109
|
+
[:block,
|
110
|
+
[:lasgn, :var1, [:lit, 1]],
|
111
|
+
[:lasgn, :var2, [:lit, 2]],
|
112
|
+
[:lasgn, :result, [:nil]],
|
113
|
+
[:case,
|
114
|
+
[:lvar, :var1],
|
115
|
+
[:when,
|
116
|
+
[:array, [:lit, 1]],
|
117
|
+
[:case,
|
118
|
+
[:lvar, :var2],
|
119
|
+
[:when, [:array, [:lit, 1]], [:lasgn, :result, [:lit, 1]]],
|
120
|
+
[:when, [:array, [:lit, 2]], [:lasgn, :result, [:lit, 2]]],
|
121
|
+
[:lasgn, :result, [:lit, 3]]]],
|
122
|
+
[:when,
|
123
|
+
[:array, [:lit, 2]],
|
118
124
|
[:case,
|
119
|
-
[:lvar, :
|
120
|
-
[:when,
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
[:when, [:array, [:lit, 1]], [:lasgn, :result, [:lit, 1]]],
|
125
|
-
[:when, [:array, [:lit, 2]], [:lasgn, :result, [:lit, 2]]],
|
126
|
-
[:lasgn, :result, [:lit, 3]]]],
|
127
|
-
[:when,
|
128
|
-
[:array, [:lit, 2]],
|
129
|
-
[:case,
|
130
|
-
[:lvar, :var2],
|
131
|
-
[:when, [:array, [:lit, 1]], [:lasgn, :result, [:lit, 4]]],
|
132
|
-
[:when, [:array, [:lit, 2]], [:lasgn, :result, [:lit, 5]]],
|
133
|
-
[:lasgn, :result, [:lit, 6]]]],
|
134
|
-
[:lasgn, :result, [:lit, 7]]]]
|
135
|
-
end
|
125
|
+
[:lvar, :var2],
|
126
|
+
[:when, [:array, [:lit, 1]], [:lasgn, :result, [:lit, 4]]],
|
127
|
+
[:when, [:array, [:lit, 2]], [:lasgn, :result, [:lit, 5]]],
|
128
|
+
[:lasgn, :result, [:lit, 6]]]],
|
129
|
+
[:lasgn, :result, [:lit, 7]]]]
|
136
130
|
end
|
137
131
|
|
138
|
-
|
132
|
+
parse <<-ruby do
|
139
133
|
case
|
140
134
|
when (a == 1) then
|
141
135
|
:a
|
@@ -146,22 +140,20 @@ describe "A Case node" do
|
|
146
140
|
end
|
147
141
|
ruby
|
148
142
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
[:lit, :c]]
|
161
|
-
end
|
143
|
+
[:case,
|
144
|
+
nil,
|
145
|
+
[:when,
|
146
|
+
[:array,
|
147
|
+
[:call, [:call, nil, :a, [:arglist]], :==, [:arglist, [:lit, 1]]]],
|
148
|
+
[:lit, :a]],
|
149
|
+
[:when,
|
150
|
+
[:array,
|
151
|
+
[:call, [:call, nil, :a, [:arglist]], :==, [:arglist, [:lit, 2]]]],
|
152
|
+
[:lit, :b]],
|
153
|
+
[:lit, :c]]
|
162
154
|
end
|
163
155
|
|
164
|
-
|
156
|
+
parse <<-ruby do
|
165
157
|
case a
|
166
158
|
when :b, *c then
|
167
159
|
d
|
@@ -170,51 +162,43 @@ describe "A Case node" do
|
|
170
162
|
end
|
171
163
|
ruby
|
172
164
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
[:call, nil, :e, [:arglist]]]
|
180
|
-
end
|
165
|
+
[:case,
|
166
|
+
[:call, nil, :a, [:arglist]],
|
167
|
+
[:when,
|
168
|
+
[:array, [:lit, :b], [:when, [:call, nil, :c, [:arglist]], nil]],
|
169
|
+
[:call, nil, :d, [:arglist]]],
|
170
|
+
[:call, nil, :e, [:arglist]]]
|
181
171
|
end
|
182
172
|
|
183
|
-
|
173
|
+
parse <<-ruby do
|
184
174
|
case true
|
185
175
|
when String, *%w(foo bar baz) then
|
186
176
|
12
|
187
177
|
end
|
188
178
|
ruby
|
189
179
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
[:when, [:array, [:str, "foo"], [:str, "bar"], [:str, "baz"]], nil]],
|
197
|
-
[:lit, 12]],
|
198
|
-
nil]
|
199
|
-
end
|
180
|
+
[:case,
|
181
|
+
[:true],
|
182
|
+
[:when,
|
183
|
+
[:array, [:const, :String], [:str, "foo"], [:str, "bar"], [:str, "baz"]],
|
184
|
+
[:lit, 12]],
|
185
|
+
nil]
|
200
186
|
end
|
201
187
|
|
202
|
-
|
188
|
+
parse <<-ruby do
|
203
189
|
case ()
|
204
190
|
when a
|
205
191
|
1
|
206
192
|
end
|
207
193
|
ruby
|
208
194
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
nil]
|
214
|
-
end
|
195
|
+
[:case,
|
196
|
+
[:nil],
|
197
|
+
[:when, [:array, [:call, nil, :a, [:arglist]]], [:lit, 1]],
|
198
|
+
nil]
|
215
199
|
end
|
216
200
|
|
217
|
-
|
201
|
+
parse <<-ruby do
|
218
202
|
x = 1
|
219
203
|
case a
|
220
204
|
when x
|
@@ -222,13 +206,11 @@ describe "A Case node" do
|
|
222
206
|
end
|
223
207
|
ruby
|
224
208
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
nil]]
|
232
|
-
end
|
209
|
+
[:block,
|
210
|
+
[:lasgn, :x, [:lit, 1]],
|
211
|
+
[:case,
|
212
|
+
[:call, nil, :a, [:arglist]],
|
213
|
+
[:when, [:array, [:lvar, :x]], [:lit, 2]],
|
214
|
+
nil]]
|
233
215
|
end
|
234
216
|
end
|
data/spec/cdecl_spec.rb
CHANGED
@@ -1,45 +1,33 @@
|
|
1
1
|
describe "A Cdecl node" do
|
2
|
-
|
3
|
-
|
4
|
-
[:cdecl, :X, [:lit, 42]]
|
5
|
-
end
|
2
|
+
parse "X = 42" do
|
3
|
+
[:cdecl, :X, [:lit, 42]]
|
6
4
|
end
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
[:cdecl, [:colon3, :X], [:lit, 1]]
|
11
|
-
end
|
6
|
+
parse "::X = 1" do
|
7
|
+
[:cdecl, [:colon3, :X], [:lit, 1]]
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
[:cdecl, [:colon2, [:const, :X], :Y], [:lit, 1]]
|
17
|
-
end
|
10
|
+
parse "X::Y = 1" do
|
11
|
+
[:cdecl, [:colon2, [:const, :X], :Y], [:lit, 1]]
|
18
12
|
end
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
[:call, nil, :a, [:arglist]]]
|
25
|
-
end
|
14
|
+
parse "X::Y::Z = a" do
|
15
|
+
[:cdecl,
|
16
|
+
[:colon2, [:colon2, [:const, :X], :Y], :Z],
|
17
|
+
[:call, nil, :a, [:arglist]]]
|
26
18
|
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
[:cdecl, [:colon2, [:call, nil, :a, [:arglist]], :A], [:lit, 1]]
|
31
|
-
end
|
20
|
+
parse "a::A = 1" do
|
21
|
+
[:cdecl, [:colon2, [:call, nil, :a, [:arglist]], :A], [:lit, 1]]
|
32
22
|
end
|
33
23
|
|
34
|
-
|
24
|
+
parse <<-ruby do
|
35
25
|
a = Object
|
36
26
|
a::B = b
|
37
27
|
ruby
|
38
28
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
[:cdecl, [:colon2, [:lvar, :a], :B], [:call, nil, :b, [:arglist]]]]
|
43
|
-
end
|
29
|
+
[:block,
|
30
|
+
[:lasgn, :a, [:const, :Object]],
|
31
|
+
[:cdecl, [:colon2, [:lvar, :a], :B], [:call, nil, :b, [:arglist]]]]
|
44
32
|
end
|
45
33
|
end
|
data/spec/class_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe "A Class node" do
|
2
|
-
|
2
|
+
parse <<-ruby do
|
3
3
|
class X
|
4
4
|
puts((1 + 1))
|
5
5
|
def blah
|
@@ -8,76 +8,64 @@ describe "A Class node" do
|
|
8
8
|
end
|
9
9
|
ruby
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
[:block, [:call, nil, :puts, [:arglist, [:str, "hello"]]]]]]]]]
|
26
|
-
end
|
11
|
+
[:class,
|
12
|
+
:X,
|
13
|
+
nil,
|
14
|
+
[:scope,
|
15
|
+
[:block,
|
16
|
+
[:call,
|
17
|
+
nil,
|
18
|
+
:puts,
|
19
|
+
[:arglist, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]]],
|
20
|
+
[:defn,
|
21
|
+
:blah,
|
22
|
+
[:args],
|
23
|
+
[:scope,
|
24
|
+
[:block, [:call, nil, :puts, [:arglist, [:str, "hello"]]]]]]]]]
|
27
25
|
end
|
28
26
|
|
29
|
-
|
27
|
+
parse <<-ruby do
|
30
28
|
class ::Y
|
31
29
|
c
|
32
30
|
end
|
33
31
|
ruby
|
34
32
|
|
35
|
-
|
36
|
-
[:class, [:colon3, :Y], nil, [:scope, [:call, nil, :c, [:arglist]]]]
|
37
|
-
end
|
33
|
+
[:class, [:colon3, :Y], nil, [:scope, [:block, [:call, nil, :c, [:arglist]]]]]
|
38
34
|
end
|
39
35
|
|
40
|
-
|
36
|
+
parse <<-ruby do
|
41
37
|
class X::Y
|
42
38
|
c
|
43
39
|
end
|
44
40
|
ruby
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
[:scope, [:call, nil, :c, [:arglist]]]]
|
51
|
-
end
|
42
|
+
[:class,
|
43
|
+
[:colon2, [:const, :X], :Y],
|
44
|
+
nil,
|
45
|
+
[:scope, [:block, [:call, nil, :c, [:arglist]]]]]
|
52
46
|
end
|
53
47
|
|
54
|
-
|
48
|
+
parse <<-ruby do
|
55
49
|
class X < Array
|
56
50
|
end
|
57
51
|
ruby
|
58
52
|
|
59
|
-
|
60
|
-
[:class, :X, [:const, :Array], [:scope]]
|
61
|
-
end
|
53
|
+
[:class, :X, [:const, :Array], [:scope]]
|
62
54
|
end
|
63
55
|
|
64
|
-
|
56
|
+
parse <<-ruby do
|
65
57
|
class X < expr
|
66
58
|
end
|
67
59
|
ruby
|
68
60
|
|
69
|
-
|
70
|
-
[:class, :X, [:call, nil, :expr, [:arglist]], [:scope]]
|
71
|
-
end
|
61
|
+
[:class, :X, [:call, nil, :expr, [:arglist]], [:scope]]
|
72
62
|
end
|
73
63
|
|
74
|
-
|
64
|
+
parse <<-ruby do
|
75
65
|
class X < Object
|
76
66
|
end
|
77
67
|
ruby
|
78
68
|
|
79
|
-
|
80
|
-
[:class, :X, [:const, :Object], [:scope]]
|
81
|
-
end
|
69
|
+
[:class, :X, [:const, :Object], [:scope]]
|
82
70
|
end
|
83
71
|
end
|