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/iasgn_spec.rb
CHANGED
@@ -1,25 +1,19 @@
|
|
1
1
|
describe "A Iasgn node" do
|
2
|
-
|
3
|
-
|
4
|
-
[:iasgn, :@a, [:lit, 4]]
|
5
|
-
end
|
2
|
+
parse "@a = 4" do
|
3
|
+
[:iasgn, :@a, [:lit, 4]]
|
6
4
|
end
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
[:iasgn, :@a, [:svalue, [:splat, [:array, [:lit, 1]]]]]
|
11
|
-
end
|
6
|
+
parse "@a = *[1]" do
|
7
|
+
[:iasgn, :@a, [:splat, [:array, [:lit, 1]]]]
|
12
8
|
end
|
13
9
|
|
14
|
-
|
10
|
+
parse <<-ruby do
|
15
11
|
a = 1
|
16
12
|
@a = a
|
17
13
|
ruby
|
18
14
|
|
19
|
-
|
20
|
-
[:
|
21
|
-
|
22
|
-
[:iasgn, :@a, [:lvar, :a]]]
|
23
|
-
end
|
15
|
+
[:block,
|
16
|
+
[:lasgn, :a, [:lit, 1]],
|
17
|
+
[:iasgn, :@a, [:lvar, :a]]]
|
24
18
|
end
|
25
19
|
end
|
data/spec/if_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe "An If node" do
|
2
|
-
|
2
|
+
parse <<-ruby do
|
3
3
|
if true then
|
4
4
|
10
|
5
5
|
else
|
@@ -7,125 +7,95 @@ describe "An If node" do
|
|
7
7
|
end
|
8
8
|
ruby
|
9
9
|
|
10
|
-
|
11
|
-
[:if, [:true], [:lit, 10], [:lit, 12]]
|
12
|
-
end
|
10
|
+
[:if, [:true], [:lit, 10], [:lit, 12]]
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
18
|
-
end
|
13
|
+
parse "if b then a end" do
|
14
|
+
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
19
15
|
end
|
20
16
|
|
21
|
-
|
17
|
+
parse <<-ruby do
|
22
18
|
if (x = 5
|
23
19
|
(x + 1)) then
|
24
20
|
nil
|
25
21
|
end
|
26
22
|
ruby
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
nil]
|
35
|
-
end
|
24
|
+
[:if,
|
25
|
+
[:block,
|
26
|
+
[:lasgn, :x, [:lit, 5]],
|
27
|
+
[:call, [:lvar, :x], :+, [:arglist, [:lit, 1]]]],
|
28
|
+
[:nil],
|
29
|
+
nil]
|
36
30
|
end
|
37
31
|
|
38
|
-
|
32
|
+
parse <<-ruby do
|
39
33
|
if x = obj.x then
|
40
34
|
x.do_it
|
41
35
|
end
|
42
36
|
ruby
|
43
37
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
nil]
|
49
|
-
end
|
38
|
+
[:if,
|
39
|
+
[:lasgn, :x, [:call, [:call, nil, :obj, [:arglist]], :x, [:arglist]]],
|
40
|
+
[:call, [:lvar, :x], :do_it, [:arglist]],
|
41
|
+
nil]
|
50
42
|
end
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
[:if, [:true], nil, [:if, [:false], [:return], nil]]
|
55
|
-
end
|
44
|
+
parse "return if false unless true" do
|
45
|
+
[:if, [:true], [:nil], [:if, [:false], [:return], nil]]
|
56
46
|
end
|
57
47
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
parse "a if not b" do
|
49
|
+
[:if,
|
50
|
+
[:call, [:call, nil, :b, [:arglist]], :!, [:arglist]],
|
51
|
+
[:call, nil, :a, [:arglist]],
|
52
|
+
nil]
|
62
53
|
end
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
67
|
-
end
|
55
|
+
parse "a if b" do
|
56
|
+
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
68
57
|
end
|
69
58
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
parse "if not b then a end" do
|
60
|
+
[:if,
|
61
|
+
[:call, [:call, nil, :b, [:arglist]], :!, [:arglist]],
|
62
|
+
[:call, nil, :a, [:arglist]],
|
63
|
+
nil]
|
74
64
|
end
|
75
65
|
|
76
|
-
|
77
|
-
|
78
|
-
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
79
|
-
end
|
66
|
+
parse "if b then a end" do
|
67
|
+
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
80
68
|
end
|
81
69
|
|
82
70
|
nil_condition_sexp = [:if, [:nil], [:call, nil, :a, [:arglist]], nil]
|
83
71
|
|
84
|
-
|
85
|
-
|
86
|
-
nil_condition_sexp
|
87
|
-
end
|
72
|
+
parse "a if ()" do
|
73
|
+
nil_condition_sexp
|
88
74
|
end
|
89
75
|
|
90
|
-
|
91
|
-
|
92
|
-
nil_condition_sexp
|
93
|
-
end
|
76
|
+
parse "if () then a end" do
|
77
|
+
nil_condition_sexp
|
94
78
|
end
|
95
79
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
80
|
+
parse "a unless not b" do
|
81
|
+
[:if,
|
82
|
+
[:call, [:call, nil, :b, [:arglist]], :!, [:arglist]],
|
83
|
+
[:nil],
|
84
|
+
[:call, nil, :a, [:arglist]]]
|
100
85
|
end
|
101
86
|
|
102
|
-
|
103
|
-
|
104
|
-
nil_condition_sexp
|
105
|
-
end
|
87
|
+
parse "a unless b" do
|
88
|
+
[:if, [:call, nil, :b, [:arglist]], [:nil], [:call, nil, :a, [:arglist]]]
|
106
89
|
end
|
107
90
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
91
|
+
parse "unless not b then a end" do
|
92
|
+
[:if,
|
93
|
+
[:call, [:call, nil, :b, [:arglist]], :!, [:arglist]],
|
94
|
+
[:nil],
|
95
|
+
[:call, nil, :a, [:arglist]]]
|
112
96
|
end
|
113
97
|
|
114
|
-
|
115
|
-
|
116
|
-
[:if, [:call, nil, :b, [:arglist]], nil, [:call, nil, :a, [:arglist]]]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
relates "unless not b then a end" do
|
121
|
-
parse do
|
122
|
-
[:if, [:call, nil, :b, [:arglist]], [:call, nil, :a, [:arglist]], nil]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
relates "unless b then a end" do
|
127
|
-
parse do
|
128
|
-
[:if, [:call, nil, :b, [:arglist]], nil, [:call, nil, :a, [:arglist]]]
|
129
|
-
end
|
98
|
+
parse "unless b then a end" do
|
99
|
+
[:if, [:call, nil, :b, [:arglist]], [:nil], [:call, nil, :a, [:arglist]]]
|
130
100
|
end
|
131
101
|
end
|
data/spec/iter_spec.rb
CHANGED
@@ -1,121 +1,113 @@
|
|
1
1
|
describe "An Iter node" do
|
2
|
-
|
3
|
-
|
4
|
-
[:iter, [:call, nil, :m, [:arglist]], nil]
|
5
|
-
end
|
2
|
+
parse "m { }" do
|
3
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:nil]]]]
|
6
4
|
end
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
[:iter, [:call, nil, :m, [:arglist]], nil]
|
11
|
-
end
|
6
|
+
parse "m do end" do
|
7
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:nil]]]]
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
[:iter,
|
17
|
-
[:call, nil, :m, [:arglist]],
|
18
|
-
nil,
|
19
|
-
[:call, nil, :x, [:arglist]]]
|
20
|
-
end
|
10
|
+
parse "m { x }" do
|
11
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:call, nil, :x, [:arglist]]]]]
|
21
12
|
end
|
22
13
|
|
23
|
-
|
24
|
-
|
25
|
-
[:iter,
|
26
|
-
[:call, nil, :m, [:arglist]],
|
27
|
-
0,
|
28
|
-
[:call, nil, :x, [:arglist]]]
|
29
|
-
end
|
14
|
+
parse "m { || x }" do
|
15
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:call, nil, :x, [:arglist]]]]]
|
30
16
|
end
|
31
17
|
|
32
|
-
|
33
|
-
|
18
|
+
parse "m { |a| a + x }" do
|
19
|
+
[:call,
|
20
|
+
nil,
|
21
|
+
:m,
|
22
|
+
[:arglist,
|
34
23
|
[:iter,
|
35
|
-
[:
|
36
|
-
[:
|
37
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
38
|
-
end
|
24
|
+
[:args, :a],
|
25
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
39
26
|
end
|
40
27
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
[:call, nil, :x, [:arglist]]]
|
47
|
-
end
|
28
|
+
parse "m { |*| x }" do
|
29
|
+
[:call,
|
30
|
+
nil,
|
31
|
+
:m,
|
32
|
+
[:arglist, [:iter, [:args, :*], [:call, nil, :x, [:arglist]]]]]
|
48
33
|
end
|
49
34
|
|
50
|
-
|
51
|
-
|
35
|
+
parse "m { |*c| x; c }" do
|
36
|
+
[:call,
|
37
|
+
nil,
|
38
|
+
:m,
|
39
|
+
[:arglist,
|
52
40
|
[:iter,
|
53
|
-
[:
|
54
|
-
[:
|
55
|
-
[:block, [:call, nil, :x, [:arglist]], [:lvar, :c]]]
|
56
|
-
end
|
41
|
+
[:args, :"*c"],
|
42
|
+
[:block, [:call, nil, :x, [:arglist]], [:lvar, :c]]]]]
|
57
43
|
end
|
58
44
|
|
59
|
-
|
60
|
-
|
45
|
+
parse "m { |a, | a + x }" do
|
46
|
+
[:call,
|
47
|
+
nil,
|
48
|
+
:m,
|
49
|
+
[:arglist,
|
61
50
|
[:iter,
|
62
|
-
[:
|
63
|
-
[:
|
64
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
65
|
-
end
|
51
|
+
[:args, :a],
|
52
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
66
53
|
end
|
67
54
|
|
68
|
-
|
69
|
-
|
55
|
+
parse "m { |a, *| a + x }" do
|
56
|
+
[:call,
|
57
|
+
nil,
|
58
|
+
:m,
|
59
|
+
[:arglist,
|
70
60
|
[:iter,
|
71
|
-
[:
|
72
|
-
[:
|
73
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
74
|
-
end
|
61
|
+
[:args, :a, :*],
|
62
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
75
63
|
end
|
76
64
|
|
77
|
-
|
78
|
-
|
65
|
+
parse "m { |a, *c| a + x; c }" do
|
66
|
+
[:call,
|
67
|
+
nil,
|
68
|
+
:m,
|
69
|
+
[:arglist,
|
79
70
|
[:iter,
|
80
|
-
[:
|
81
|
-
[:masgn, [:array, [:lasgn, :a], [:splat, [:lasgn, :c]]]],
|
71
|
+
[:args, :a, :"*c"],
|
82
72
|
[:block,
|
83
73
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
84
|
-
[:lvar, :c]]]
|
85
|
-
end
|
74
|
+
[:lvar, :c]]]]]
|
86
75
|
end
|
87
76
|
|
88
|
-
|
89
|
-
|
77
|
+
parse "m { |a, b| a + x; b }" do
|
78
|
+
[:call,
|
79
|
+
nil,
|
80
|
+
:m,
|
81
|
+
[:arglist,
|
90
82
|
[:iter,
|
91
|
-
[:
|
92
|
-
[:masgn, [:array, [:lasgn, :a], [:lasgn, :b]]],
|
83
|
+
[:args, :a, :b],
|
93
84
|
[:block,
|
94
85
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
95
|
-
[:lvar, :b]]]
|
96
|
-
end
|
86
|
+
[:lvar, :b]]]]]
|
97
87
|
end
|
98
88
|
|
99
|
-
|
100
|
-
|
89
|
+
parse "m { |a, b, | a + x; b }" do
|
90
|
+
[:call,
|
91
|
+
nil,
|
92
|
+
:m,
|
93
|
+
[:arglist,
|
101
94
|
[:iter,
|
102
|
-
[:
|
103
|
-
[:masgn, [:array, [:lasgn, :a], [:lasgn, :b]]],
|
95
|
+
[:args, :a, :b],
|
104
96
|
[:block,
|
105
97
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
106
|
-
[:lvar, :b]]]
|
107
|
-
end
|
98
|
+
[:lvar, :b]]]]]
|
108
99
|
end
|
109
100
|
|
110
|
-
|
111
|
-
|
101
|
+
parse "m { |a, b, *| a + x; b }" do
|
102
|
+
[:call,
|
103
|
+
nil,
|
104
|
+
:m,
|
105
|
+
[:arglist,
|
112
106
|
[:iter,
|
113
|
-
[:
|
114
|
-
[:masgn, [:array, [:lasgn, :a], [:lasgn, :b], [:splat]]],
|
107
|
+
[:args, :a, :b, :*],
|
115
108
|
[:block,
|
116
109
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
117
|
-
[:lvar, :b]]]
|
118
|
-
end
|
110
|
+
[:lvar, :b]]]]]
|
119
111
|
end
|
120
112
|
|
121
113
|
masgn_rest_arg_block = lambda do |g|
|
@@ -133,144 +125,147 @@ describe "An Iter node" do
|
|
133
125
|
end
|
134
126
|
end
|
135
127
|
|
136
|
-
|
137
|
-
|
128
|
+
parse "m { |a, b, *c| a + x; b; c }" do
|
129
|
+
[:call,
|
130
|
+
nil,
|
131
|
+
:m,
|
132
|
+
[:arglist,
|
138
133
|
[:iter,
|
139
|
-
[:
|
140
|
-
[:masgn, [:array, [:lasgn, :a], [:lasgn, :b], [:splat, [:lasgn, :c]]]],
|
134
|
+
[:args, :a, :b, :"*c"],
|
141
135
|
[:block,
|
142
136
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
143
137
|
[:lvar, :b],
|
144
|
-
[:lvar, :c]]]
|
145
|
-
end
|
138
|
+
[:lvar, :c]]]]]
|
146
139
|
end
|
147
140
|
|
148
|
-
|
149
|
-
|
141
|
+
parse "m do |a, b, *c| a + x; b; c end" do
|
142
|
+
[:call,
|
143
|
+
nil,
|
144
|
+
:m,
|
145
|
+
[:arglist,
|
150
146
|
[:iter,
|
151
|
-
[:
|
152
|
-
[:masgn, [:array, [:lasgn, :a], [:lasgn, :b], [:splat, [:lasgn, :c]]]],
|
147
|
+
[:args, :a, :b, :"*c"],
|
153
148
|
[:block,
|
154
149
|
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]],
|
155
150
|
[:lvar, :b],
|
156
|
-
[:lvar, :c]]]
|
157
|
-
end
|
151
|
+
[:lvar, :c]]]]]
|
158
152
|
end
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
[:block, [:lasgn, :n, [:lit, 1]], [:lvar, :n]]]
|
166
|
-
end
|
154
|
+
parse "m { n = 1; n }" do
|
155
|
+
[:call,
|
156
|
+
nil,
|
157
|
+
:m,
|
158
|
+
[:arglist, [:iter, [:args], [:block, [:lasgn, :n, [:lit, 1]], [:lvar, :n]]]]]
|
167
159
|
end
|
168
160
|
|
169
|
-
|
170
|
-
|
161
|
+
parse "m { n = 1; m { n } }" do
|
162
|
+
[:call,
|
163
|
+
nil,
|
164
|
+
:m,
|
165
|
+
[:arglist,
|
171
166
|
[:iter,
|
172
|
-
[:
|
173
|
-
nil,
|
167
|
+
[:args],
|
174
168
|
[:block,
|
175
169
|
[:lasgn, :n, [:lit, 1]],
|
176
|
-
[:
|
177
|
-
end
|
170
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:lvar, :n]]]]]]]]
|
178
171
|
end
|
179
172
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
[:lvar, :n]]
|
186
|
-
end
|
173
|
+
parse "n = 1; m { n = 2 }; n" do
|
174
|
+
[:block,
|
175
|
+
[:lasgn, :n, [:lit, 1]],
|
176
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:lasgn, :n, [:lit, 2]]]]],
|
177
|
+
[:lvar, :n]]
|
187
178
|
end
|
188
179
|
|
189
|
-
|
190
|
-
|
180
|
+
parse "m(a) { |b| a + x }" do
|
181
|
+
[:call,
|
182
|
+
nil,
|
183
|
+
:m,
|
184
|
+
[:arglist,
|
185
|
+
[:call, nil, :a, [:arglist]],
|
191
186
|
[:iter,
|
192
|
-
[:
|
193
|
-
[:lasgn, :b],
|
187
|
+
[:args, :b],
|
194
188
|
[:call,
|
195
189
|
[:call, nil, :a, [:arglist]],
|
196
190
|
:+,
|
197
|
-
[:arglist, [:call, nil, :x, [:arglist]]]]]
|
198
|
-
end
|
191
|
+
[:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
199
192
|
end
|
200
193
|
|
201
|
-
|
194
|
+
parse <<-ruby do
|
202
195
|
m { |a|
|
203
196
|
a + x
|
204
197
|
}
|
205
198
|
ruby
|
206
199
|
|
207
|
-
|
200
|
+
[:call,
|
201
|
+
nil,
|
202
|
+
:m,
|
203
|
+
[:arglist,
|
208
204
|
[:iter,
|
209
|
-
[:
|
210
|
-
[:
|
211
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
212
|
-
end
|
205
|
+
[:args, :a],
|
206
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
213
207
|
end
|
214
208
|
|
215
|
-
|
209
|
+
parse <<-ruby do
|
216
210
|
m do |a|
|
217
211
|
a + x
|
218
212
|
end
|
219
213
|
ruby
|
220
214
|
|
221
|
-
|
215
|
+
[:call,
|
216
|
+
nil,
|
217
|
+
:m,
|
218
|
+
[:arglist,
|
222
219
|
[:iter,
|
223
|
-
[:
|
224
|
-
[:
|
225
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
226
|
-
end
|
220
|
+
[:args, :a],
|
221
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
227
222
|
end
|
228
223
|
|
229
|
-
|
230
|
-
|
224
|
+
parse "obj.m { |a| a + x }" do
|
225
|
+
[:call,
|
226
|
+
[:call, nil, :obj, [:arglist]],
|
227
|
+
:m,
|
228
|
+
[:arglist,
|
231
229
|
[:iter,
|
232
|
-
[:
|
233
|
-
[:
|
234
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
235
|
-
end
|
230
|
+
[:args, :a],
|
231
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
236
232
|
end
|
237
233
|
|
238
|
-
|
239
|
-
|
234
|
+
parse "obj.m(x) { |a| a + x }" do
|
235
|
+
[:call,
|
236
|
+
[:call, nil, :obj, [:arglist]],
|
237
|
+
:m,
|
238
|
+
[:arglist,
|
239
|
+
[:call, nil, :x, [:arglist]],
|
240
240
|
[:iter,
|
241
|
-
[:
|
242
|
-
|
243
|
-
:m,
|
244
|
-
[:arglist, [:call, nil, :x, [:arglist]]]],
|
245
|
-
[:lasgn, :a],
|
246
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
247
|
-
end
|
241
|
+
[:args, :a],
|
242
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
248
243
|
end
|
249
244
|
|
250
|
-
|
251
|
-
|
245
|
+
parse "obj.m(a) { |a| a + x }" do
|
246
|
+
[:call,
|
247
|
+
[:call, nil, :obj, [:arglist]],
|
248
|
+
:m,
|
249
|
+
[:arglist,
|
250
|
+
[:call, nil, :a, [:arglist]],
|
252
251
|
[:iter,
|
253
|
-
[:
|
254
|
-
|
255
|
-
:m,
|
256
|
-
[:arglist, [:call, nil, :a, [:arglist]]]],
|
257
|
-
[:lasgn, :a],
|
258
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]
|
259
|
-
end
|
252
|
+
[:args, :a],
|
253
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]
|
260
254
|
end
|
261
255
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
256
|
+
parse "a = 1; m { |a| a + x }" do
|
257
|
+
[:block,
|
258
|
+
[:lasgn, :a, [:lit, 1]],
|
259
|
+
[:call,
|
260
|
+
nil,
|
261
|
+
:m,
|
262
|
+
[:arglist,
|
266
263
|
[:iter,
|
267
|
-
[:
|
268
|
-
[:
|
269
|
-
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]
|
270
|
-
end
|
264
|
+
[:args, :a],
|
265
|
+
[:call, [:lvar, :a], :+, [:arglist, [:call, nil, :x, [:arglist]]]]]]]]
|
271
266
|
end
|
272
267
|
|
273
|
-
|
268
|
+
parse <<-ruby do
|
274
269
|
x = nil
|
275
270
|
m do |a|
|
276
271
|
begin
|
@@ -283,331 +278,262 @@ describe "An Iter node" do
|
|
283
278
|
end
|
284
279
|
ruby
|
285
280
|
|
286
|
-
|
287
|
-
|
288
|
-
|
281
|
+
[:block,
|
282
|
+
[:lasgn, :x, [:nil]],
|
283
|
+
[:call,
|
284
|
+
nil,
|
285
|
+
:m,
|
286
|
+
[:arglist,
|
289
287
|
[:iter,
|
290
|
-
[:
|
291
|
-
[:lasgn, :a],
|
288
|
+
[:args, :a],
|
292
289
|
[:ensure,
|
293
290
|
[:rescue,
|
294
291
|
[:lvar, :x],
|
295
292
|
[:resbody,
|
296
293
|
[:array, [:const, :Exception], [:lasgn, :x, [:gvar, :$!]]],
|
297
|
-
[:break]]],
|
298
|
-
[:lasgn, :x, [:lvar, :a]]]]]
|
299
|
-
end
|
294
|
+
[:break, [:nil]]]],
|
295
|
+
[:lasgn, :x, [:lvar, :a]]]]]]]
|
300
296
|
end
|
301
297
|
|
302
|
-
|
303
|
-
|
304
|
-
[:iter, [:call, nil, :m, [:arglist]], nil, [:next]]
|
305
|
-
end
|
298
|
+
parse "m { next }" do
|
299
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:next]]]]
|
306
300
|
end
|
307
301
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
302
|
+
parse "m { next if x }" do
|
303
|
+
[:call,
|
304
|
+
nil,
|
305
|
+
:m,
|
306
|
+
[:arglist,
|
307
|
+
[:iter, [:args], [:if, [:call, nil, :x, [:arglist]], [:next], nil]]]]
|
315
308
|
end
|
316
309
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
[:next, [:call, nil, :x, [:arglist]]]]
|
323
|
-
end
|
310
|
+
parse "m { next x }" do
|
311
|
+
[:call,
|
312
|
+
nil,
|
313
|
+
:m,
|
314
|
+
[:arglist, [:iter, [:args], [:next, [:call, nil, :x, [:arglist]]]]]]
|
324
315
|
end
|
325
316
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
[:lasgn, :x, [:lit, 1]],
|
333
|
-
[:next, [:lvar, :x]]]]
|
334
|
-
end
|
317
|
+
parse "m { x = 1; next x }" do
|
318
|
+
[:call,
|
319
|
+
nil,
|
320
|
+
:m,
|
321
|
+
[:arglist,
|
322
|
+
[:iter, [:args], [:block, [:lasgn, :x, [:lit, 1]], [:next, [:lvar, :x]]]]]]
|
335
323
|
end
|
336
324
|
|
337
|
-
|
338
|
-
|
339
|
-
[:iter, [:call, nil, :m, [:arglist]], nil, [:next, [:array, [:lit, 1]]]]
|
340
|
-
end
|
325
|
+
parse "m { next [1] }" do
|
326
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:next, [:array, [:lit, 1]]]]]]
|
341
327
|
end
|
342
328
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
[:next, [:svalue, [:splat, [:array, [:lit, 1]]]]]]
|
349
|
-
end
|
329
|
+
parse "m { next *[1] }" do
|
330
|
+
[:call,
|
331
|
+
nil,
|
332
|
+
:m,
|
333
|
+
[:arglist, [:iter, [:args], [:next, [:splat, [:array, [:lit, 1]]]]]]]
|
350
334
|
end
|
351
335
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
[:next, [:array, [:splat, [:array, [:lit, 1]]]]]]
|
358
|
-
end
|
336
|
+
parse "m { next [*[1]] }" do
|
337
|
+
[:call,
|
338
|
+
nil,
|
339
|
+
:m,
|
340
|
+
[:arglist, [:iter, [:args], [:next, [:splat, [:array, [:lit, 1]]]]]]]
|
359
341
|
end
|
360
342
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
end
|
343
|
+
parse "m { next *[1, 2] }" do
|
344
|
+
[:call,
|
345
|
+
nil,
|
346
|
+
:m,
|
347
|
+
[:arglist,
|
348
|
+
[:iter, [:args], [:next, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
368
349
|
end
|
369
350
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
end
|
351
|
+
parse "m { next [*[1, 2]] }" do
|
352
|
+
[:call,
|
353
|
+
nil,
|
354
|
+
:m,
|
355
|
+
[:arglist,
|
356
|
+
[:iter, [:args], [:next, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
377
357
|
end
|
378
358
|
|
379
|
-
|
380
|
-
|
381
|
-
[:iter, [:call, nil, :m, [:arglist]], nil, [:break]]
|
382
|
-
end
|
359
|
+
parse "m { break }" do
|
360
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:break, [:nil]]]]]
|
383
361
|
end
|
384
362
|
|
385
|
-
|
386
|
-
|
363
|
+
parse "m { break if x }" do
|
364
|
+
[:call,
|
365
|
+
nil,
|
366
|
+
:m,
|
367
|
+
[:arglist,
|
387
368
|
[:iter,
|
388
|
-
[:
|
389
|
-
nil,
|
390
|
-
[:if, [:call, nil, :x, [:arglist]], [:break], nil]]
|
391
|
-
end
|
369
|
+
[:args],
|
370
|
+
[:if, [:call, nil, :x, [:arglist]], [:break, [:nil]], nil]]]]
|
392
371
|
end
|
393
372
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
[:break, [:call, nil, :x, [:arglist]]]]
|
400
|
-
end
|
373
|
+
parse "m { break x }" do
|
374
|
+
[:call,
|
375
|
+
nil,
|
376
|
+
:m,
|
377
|
+
[:arglist, [:iter, [:args], [:break, [:call, nil, :x, [:arglist]]]]]]
|
401
378
|
end
|
402
379
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
[:lasgn, :x, [:lit, 1]],
|
410
|
-
[:break, [:lvar, :x]]]]
|
411
|
-
end
|
380
|
+
parse "m { x = 1; break x }" do
|
381
|
+
[:call,
|
382
|
+
nil,
|
383
|
+
:m,
|
384
|
+
[:arglist,
|
385
|
+
[:iter, [:args], [:block, [:lasgn, :x, [:lit, 1]], [:break, [:lvar, :x]]]]]]
|
412
386
|
end
|
413
387
|
|
414
|
-
|
415
|
-
|
416
|
-
[:iter,
|
417
|
-
[:call, nil, :m, [:arglist]],
|
418
|
-
nil,
|
419
|
-
[:break, [:array, [:lit, 1]]]]
|
420
|
-
end
|
388
|
+
parse "m { break [1] }" do
|
389
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:break, [:array, [:lit, 1]]]]]]
|
421
390
|
end
|
422
391
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
[:break, [:svalue, [:splat, [:array, [:lit, 1]]]]]]
|
429
|
-
end
|
392
|
+
parse "m { break *[1] }" do
|
393
|
+
[:call,
|
394
|
+
nil,
|
395
|
+
:m,
|
396
|
+
[:arglist, [:iter, [:args], [:break, [:splat, [:array, [:lit, 1]]]]]]]
|
430
397
|
end
|
431
398
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
[:break, [:array, [:splat, [:array, [:lit, 1]]]]]]
|
438
|
-
end
|
399
|
+
parse "m { break [*[1]] }" do
|
400
|
+
[:call,
|
401
|
+
nil,
|
402
|
+
:m,
|
403
|
+
[:arglist, [:iter, [:args], [:break, [:splat, [:array, [:lit, 1]]]]]]]
|
439
404
|
end
|
440
405
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
end
|
406
|
+
parse "m { break *[1, 2] }" do
|
407
|
+
[:call,
|
408
|
+
nil,
|
409
|
+
:m,
|
410
|
+
[:arglist,
|
411
|
+
[:iter, [:args], [:break, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
448
412
|
end
|
449
413
|
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
end
|
414
|
+
parse "m { break [*[1, 2]] }" do
|
415
|
+
[:call,
|
416
|
+
nil,
|
417
|
+
:m,
|
418
|
+
[:arglist,
|
419
|
+
[:iter, [:args], [:break, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
457
420
|
end
|
458
421
|
|
459
|
-
|
460
|
-
|
461
|
-
[:iter, [:call, nil, :m, [:arglist]], nil, [:return]]
|
462
|
-
end
|
422
|
+
parse "m { return }" do
|
423
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:return]]]]
|
463
424
|
end
|
464
425
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
end
|
426
|
+
parse "m { return if x }" do
|
427
|
+
[:call,
|
428
|
+
nil,
|
429
|
+
:m,
|
430
|
+
[:arglist,
|
431
|
+
[:iter, [:args], [:if, [:call, nil, :x, [:arglist]], [:return], nil]]]]
|
472
432
|
end
|
473
433
|
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
[:return, [:call, nil, :x, [:arglist]]]]
|
480
|
-
end
|
434
|
+
parse "m { return x }" do
|
435
|
+
[:call,
|
436
|
+
nil,
|
437
|
+
:m,
|
438
|
+
[:arglist, [:iter, [:args], [:return, [:call, nil, :x, [:arglist]]]]]]
|
481
439
|
end
|
482
440
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
[:lasgn, :x, [:lit, 1]],
|
490
|
-
[:return, [:lvar, :x]]]]
|
491
|
-
end
|
441
|
+
parse "m { x = 1; return x }" do
|
442
|
+
[:call,
|
443
|
+
nil,
|
444
|
+
:m,
|
445
|
+
[:arglist,
|
446
|
+
[:iter, [:args], [:block, [:lasgn, :x, [:lit, 1]], [:return, [:lvar, :x]]]]]]
|
492
447
|
end
|
493
448
|
|
494
|
-
|
495
|
-
|
496
|
-
[:iter,
|
497
|
-
[:call, nil, :m, [:arglist]],
|
498
|
-
nil,
|
499
|
-
[:return, [:array, [:lit, 1]]]]
|
500
|
-
end
|
449
|
+
parse "m { return [1] }" do
|
450
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:return, [:array, [:lit, 1]]]]]]
|
501
451
|
end
|
502
452
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
[:return, [:svalue, [:splat, [:array, [:lit, 1]]]]]]
|
509
|
-
end
|
453
|
+
parse "m { return *[1] }" do
|
454
|
+
[:call,
|
455
|
+
nil,
|
456
|
+
:m,
|
457
|
+
[:arglist, [:iter, [:args], [:return, [:splat, [:array, [:lit, 1]]]]]]]
|
510
458
|
end
|
511
459
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
[:return, [:array, [:splat, [:array, [:lit, 1]]]]]]
|
518
|
-
end
|
460
|
+
parse "m { return [*[1]] }" do
|
461
|
+
[:call,
|
462
|
+
nil,
|
463
|
+
:m,
|
464
|
+
[:arglist, [:iter, [:args], [:return, [:splat, [:array, [:lit, 1]]]]]]]
|
519
465
|
end
|
520
466
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
end
|
467
|
+
parse "m { return *[1, 2] }" do
|
468
|
+
[:call,
|
469
|
+
nil,
|
470
|
+
:m,
|
471
|
+
[:arglist,
|
472
|
+
[:iter, [:args], [:return, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
528
473
|
end
|
529
474
|
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
end
|
475
|
+
parse "m { return [*[1, 2]] }" do
|
476
|
+
[:call,
|
477
|
+
nil,
|
478
|
+
:m,
|
479
|
+
[:arglist,
|
480
|
+
[:iter, [:args], [:return, [:splat, [:array, [:lit, 1], [:lit, 2]]]]]]]
|
537
481
|
end
|
538
482
|
|
539
|
-
|
540
|
-
|
541
|
-
[:iter, [:call, nil, :m, [:arglist]], nil, [:redo]]
|
542
|
-
end
|
483
|
+
parse "m { redo }" do
|
484
|
+
[:call, nil, :m, [:arglist, [:iter, [:args], [:redo]]]]
|
543
485
|
end
|
544
486
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
end
|
487
|
+
parse "m { redo if x }" do
|
488
|
+
[:call,
|
489
|
+
nil,
|
490
|
+
:m,
|
491
|
+
[:arglist,
|
492
|
+
[:iter, [:args], [:if, [:call, nil, :x, [:arglist]], [:redo], nil]]]]
|
552
493
|
end
|
553
494
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
[:retry]]
|
560
|
-
end
|
561
|
-
|
562
|
-
# TODO
|
495
|
+
parse "m(a) { retry }" do
|
496
|
+
[:call,
|
497
|
+
nil,
|
498
|
+
:m,
|
499
|
+
[:arglist, [:call, nil, :a, [:arglist]], [:iter, [:args], [:retry]]]]
|
563
500
|
end
|
564
501
|
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
# TODO
|
502
|
+
parse "m(a) { retry if x }" do
|
503
|
+
[:call,
|
504
|
+
nil,
|
505
|
+
:m,
|
506
|
+
[:arglist,
|
507
|
+
[:call, nil, :a, [:arglist]],
|
508
|
+
[:iter, [:args], [:if, [:call, nil, :x, [:arglist]], [:retry], nil]]]]
|
574
509
|
end
|
575
510
|
|
576
|
-
|
577
|
-
|
578
|
-
[:break]
|
579
|
-
end
|
511
|
+
parse "break" do
|
512
|
+
[:break, [:nil]]
|
580
513
|
end
|
581
514
|
|
582
|
-
|
583
|
-
|
584
|
-
[:redo]
|
585
|
-
end
|
515
|
+
parse "redo" do
|
516
|
+
[:redo]
|
586
517
|
end
|
587
518
|
|
588
|
-
|
589
|
-
|
590
|
-
[:retry]
|
591
|
-
end
|
519
|
+
parse "retry" do
|
520
|
+
[:retry]
|
592
521
|
end
|
593
522
|
|
594
|
-
|
595
|
-
|
596
|
-
[:next]
|
597
|
-
end
|
523
|
+
parse "next" do
|
524
|
+
[:next]
|
598
525
|
end
|
599
526
|
|
600
|
-
|
527
|
+
parse <<-ruby do
|
601
528
|
def x(a)
|
602
529
|
bar { super }
|
603
530
|
end
|
604
531
|
ruby
|
605
532
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
end
|
533
|
+
[:defn,
|
534
|
+
:x,
|
535
|
+
[:args, :a],
|
536
|
+
[:scope,
|
537
|
+
[:block, [:call, nil, :bar, [:arglist, [:iter, [:args], [:zsuper]]]]]]]
|
612
538
|
end
|
613
539
|
end
|