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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +2 -9
  4. data/Gemfile +0 -4
  5. data/Rakefile +26 -19
  6. data/ext/rubinius/melbourne/extconf.rb +4 -3
  7. data/ext/rubinius/melbourne/grammar.cpp +2 -2
  8. data/ext/rubinius/melbourne/grammar.y +2 -2
  9. data/ext/rubinius/melbourne/melbourne.cpp +4 -5
  10. data/lib/rubinius/melbourne/version.rb +2 -2
  11. data/lib/rubinius/melbourne.rb +1 -21
  12. data/rubinius-melbourne.gemspec +6 -3
  13. data/spec/alias_spec.rb +13 -18
  14. data/spec/and_spec.rb +6 -12
  15. data/spec/array_spec.rb +28 -54
  16. data/spec/attrasgn_spec.rb +60 -85
  17. data/spec/back_ref_spec.rb +6 -8
  18. data/spec/call_spec.rb +137 -225
  19. data/spec/case_spec.rb +94 -112
  20. data/spec/cdecl_spec.rb +16 -28
  21. data/spec/class_spec.rb +28 -40
  22. data/spec/colon2_spec.rb +2 -4
  23. data/spec/colon3_spec.rb +2 -4
  24. data/spec/const_spec.rb +2 -4
  25. data/spec/custom/runner/relates.rb +4 -0
  26. data/spec/cvar_spec.rb +6 -12
  27. data/spec/cvasgn_spec.rb +20 -15
  28. data/spec/defined_spec.rb +57 -55
  29. data/spec/defn_spec.rb +218 -280
  30. data/spec/defs_spec.rb +30 -38
  31. data/spec/dot2_spec.rb +2 -4
  32. data/spec/dot3_spec.rb +2 -4
  33. data/spec/dregx_spec.rb +20 -34
  34. data/spec/dstr_spec.rb +87 -111
  35. data/spec/dsym_spec.rb +5 -7
  36. data/spec/dxstr_spec.rb +2 -4
  37. data/spec/ensure_spec.rb +32 -40
  38. data/spec/false_spec.rb +2 -4
  39. data/spec/flip2_spec.rb +22 -26
  40. data/spec/flip3_spec.rb +15 -17
  41. data/spec/for_spec.rb +25 -23
  42. data/spec/gasgn_spec.rb +4 -8
  43. data/spec/gvar_spec.rb +8 -16
  44. data/spec/hash_spec.rb +14 -18
  45. data/spec/iasgn_spec.rb +8 -14
  46. data/spec/if_spec.rb +50 -80
  47. data/spec/iter_spec.rb +328 -402
  48. data/spec/lasgn_spec.rb +143 -200
  49. data/spec/lit_spec.rb +20 -40
  50. data/spec/masgn_spec.rb +278 -309
  51. data/spec/match2_spec.rb +6 -10
  52. data/spec/match3_spec.rb +9 -13
  53. data/spec/match_spec.rb +2 -4
  54. data/spec/module_spec.rb +12 -16
  55. data/spec/nil_spec.rb +2 -4
  56. data/spec/not_spec.rb +6 -8
  57. data/spec/nth_ref_spec.rb +2 -4
  58. data/spec/op_asgn_spec.rb +118 -158
  59. data/spec/or_spec.rb +18 -24
  60. data/spec/postexe_spec.rb +2 -4
  61. data/spec/regex_spec.rb +11 -19
  62. data/spec/rescue_spec.rb +135 -143
  63. data/spec/return_spec.rb +19 -36
  64. data/spec/sclass_spec.rb +26 -25
  65. data/spec/spec_helper.rb +9 -0
  66. data/spec/str_spec.rb +25 -43
  67. data/spec/super_spec.rb +31 -49
  68. data/spec/true_spec.rb +2 -4
  69. data/spec/undef_spec.rb +38 -53
  70. data/spec/until_spec.rb +13 -105
  71. data/spec/valias_spec.rb +2 -4
  72. data/spec/while_spec.rb +35 -117
  73. data/spec/xstr_spec.rb +2 -4
  74. data/spec/yield_spec.rb +22 -42
  75. data/spec/zsuper_spec.rb +8 -16
  76. metadata +64 -22
  77. data/spec/cvdecl_spec.rb +0 -12
data/spec/defs_spec.rb CHANGED
@@ -1,20 +1,18 @@
1
1
  describe "A Defs node" do
2
- relates <<-ruby do
2
+ parse <<-ruby do
3
3
  def self.x(y)
4
4
  (y + 1)
5
5
  end
6
6
  ruby
7
7
 
8
- parse do
9
- [:defs,
10
- [:self],
11
- :x,
12
- [:args, :y],
13
- [:scope, [:block, [:call, [:lvar, :y], :+, [:arglist, [:lit, 1]]]]]]
14
- end
8
+ [:defs,
9
+ [:self],
10
+ :x,
11
+ [:args, :y],
12
+ [:scope, [:block, [:call, [:lvar, :y], :+, [:arglist, [:lit, 1]]]]]]
15
13
  end
16
14
 
17
- relates <<-ruby do
15
+ parse <<-ruby do
18
16
  def self.setup(ctx)
19
17
  bind = allocate
20
18
  bind.context = ctx
@@ -22,60 +20,54 @@ describe "A Defs node" do
22
20
  end
23
21
  ruby
24
22
 
25
- parse do
26
- [:defs,
27
- [:self],
28
- :setup,
29
- [:args, :ctx],
30
- [:scope,
31
- [:block,
32
- [:lasgn, :bind, [:call, nil, :allocate, [:arglist]]],
33
- [:attrasgn, [:lvar, :bind], :context=, [:arglist, [:lvar, :ctx]]],
34
- [:return, [:lvar, :bind]]]]]
35
- end
23
+ [:defs,
24
+ [:self],
25
+ :setup,
26
+ [:args, :ctx],
27
+ [:scope,
28
+ [:block,
29
+ [:lasgn, :bind, [:call, nil, :allocate, [:arglist]]],
30
+ [:attrasgn, [:lvar, :bind], :context=, [:arglist, [:lvar, :ctx]]],
31
+ [:return, [:lvar, :bind]]]]]
36
32
  end
37
33
 
38
- relates <<-ruby do
34
+ parse <<-ruby do
39
35
  def self.empty(*)
40
36
  end
41
37
  ruby
42
38
 
43
- parse do
44
- [:defs, [:self], :empty, [:args, :*], [:scope, [:block]]]
45
- end
39
+ [:defs, [:self], :empty, [:args, :*], [:scope, [:block, [:nil]]]]
46
40
  end
47
41
 
48
- relates <<-ruby do
42
+ parse <<-ruby do
49
43
  def self.empty
50
44
  end
51
45
  ruby
52
46
 
53
- parse do
54
- [:defs, [:self], :empty, [:args], [:scope, [:block]]]
55
- end
47
+ [:defs, [:self], :empty, [:args], [:scope, [:block, [:nil]]]]
56
48
  end
57
49
 
58
- relates <<-ruby do
50
+ parse <<-ruby do
59
51
  def (a.b).empty(*)
60
52
  end
61
53
  ruby
62
54
 
63
- parse do
64
- [:defs,
65
- [:call, [:call, nil, :a, [:arglist]], :b, [:arglist]],
66
- :empty,
67
- [:args, :*],
68
- [:scope, [:block]]]
69
- end
55
+ [:defs,
56
+ [:call, [:call, nil, :a, [:arglist]], :b, [:arglist]],
57
+ :empty,
58
+ [:args, :*],
59
+ [:scope, [:block, [:nil]]]]
70
60
  end
71
61
 
72
- relates <<-ruby do
62
+ parse <<-ruby do
73
63
  x = "a"
74
64
  def x.m(a)
75
65
  a
76
66
  end
77
67
  ruby
78
68
 
79
- # TODO
69
+ [:block,
70
+ [:lasgn, :x, [:str, "a"]],
71
+ [:defs, [:lvar, :x], :m, [:args, :a], [:scope, [:block, [:lvar, :a]]]]]
80
72
  end
81
73
  end
data/spec/dot2_spec.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  describe "A Dot2 node" do
2
- relates "(a..b)" do
3
- parse do
4
- [:dot2, [:call, nil, :a, [:arglist]], [:call, nil, :b, [:arglist]]]
5
- end
2
+ parse "(a..b)" do
3
+ [:dot2, [:call, nil, :a, [:arglist]], [:call, nil, :b, [:arglist]]]
6
4
  end
7
5
  end
data/spec/dot3_spec.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  describe "A Dot3 node" do
2
- relates "(a...b)" do
3
- parse do
4
- [:dot3, [:call, nil, :a, [:arglist]], [:call, nil, :b, [:arglist]]]
5
- end
2
+ parse "(a...b)" do
3
+ [:dot3, [:call, nil, :a, [:arglist]], [:call, nil, :b, [:arglist]]]
6
4
  end
7
5
  end
data/spec/dregx_spec.rb CHANGED
@@ -1,52 +1,38 @@
1
1
  describe "A Dregx node" do
2
- relates <<-ruby do
2
+ parse <<-ruby do
3
3
  /(\#{})/
4
4
  ruby
5
5
 
6
- parse do
7
- [:dregx, "(", [:str, ""], [:str, ")"]]
8
- end
6
+ [:dregx, "(", [:evstr, [:nil]], [:str, ")"]]
9
7
  end
10
8
 
11
- relates "/x\#{(1 + 1)}y/" do
12
- parse do
13
- [:dregx,
14
- "x",
15
- [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
16
- [:str, "y"]]
17
- end
9
+ parse "/x\#{(1 + 1)}y/" do
10
+ [:dregx,
11
+ "x",
12
+ [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
13
+ [:str, "y"]]
18
14
  end
19
15
 
20
- relates "/a\#{}b/" do
21
- parse do
22
- [:dregx, "a", [:str, ""], [:str, "b"]]
23
- end
16
+ parse "/a\#{}b/" do
17
+ [:dregx, "a", [:evstr, [:nil]], [:str, "b"]]
24
18
  end
25
19
 
26
- relates "/\#{@rakefile}/" do
27
- parse do
28
- [:dregx, "", [:evstr, [:ivar, :@rakefile]]]
29
- end
20
+ parse "/\#{@rakefile}/" do
21
+ [:dregx, "", [:evstr, [:ivar, :@rakefile]]]
30
22
  end
31
23
 
32
- relates "/\#{1}/n" do
33
- parse do
34
- [:dregx, "", [:evstr, [:lit, 1]], 16]
35
- end
24
+ parse "/\#{1}/n" do
25
+ [:dregx, "", [:evstr, [:lit, 1]], 512]
36
26
  end
37
27
 
38
- relates "/\#{IAC}\#{SB}/no" do
39
- parse do
40
- [:dregx_once, "", [:evstr, [:const, :IAC]], [:evstr, [:const, :SB]], 16]
41
- end
28
+ parse "/\#{IAC}\#{SB}/no" do
29
+ [:dregx_once, "", [:evstr, [:const, :IAC]], [:evstr, [:const, :SB]], 512]
42
30
  end
43
31
 
44
- relates "/x\#{(1 + 1)}y/o" do
45
- parse do
46
- [:dregx_once,
47
- "x",
48
- [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
49
- [:str, "y"]]
50
- end
32
+ parse "/x\#{(1 + 1)}y/o" do
33
+ [:dregx_once,
34
+ "x",
35
+ [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
36
+ [:str, "y"]]
51
37
  end
52
38
  end
data/spec/dstr_spec.rb CHANGED
@@ -1,169 +1,145 @@
1
1
  describe "A Dstr node" do
2
- relates <<-ruby do
2
+ parse <<-ruby do
3
3
  "hello \#{}"
4
4
  ruby
5
5
 
6
- parse do
7
- [:dstr, "hello ", [:str, ""]]
8
- end
6
+ [:dstr, "hello ", [:evstr, [:nil]]]
9
7
  end
10
8
 
11
- relates <<-ruby do
9
+ parse <<-ruby do
12
10
  argl = 1
13
11
  "x\#{argl}y"
14
12
  ruby
15
13
 
16
- parse do
17
- [:block,
18
- [:lasgn, :argl, [:lit, 1]],
19
- [:dstr, "x", [:evstr, [:lvar, :argl]], [:str, "y"]]]
20
- end
14
+ [:block,
15
+ [:lasgn, :argl, [:lit, 1]],
16
+ [:dstr, "x", [:evstr, [:lvar, :argl]], [:str, "y"]]]
21
17
  end
22
18
 
23
- relates <<-ruby do
19
+ parse <<-ruby do
24
20
  argl = 1
25
21
  "x\#{("%.2f" % 3.14159)}y"
26
22
  ruby
27
23
 
28
- parse do
29
- [:block,
30
- [:lasgn, :argl, [:lit, 1]],
31
- [:dstr,
32
- "x",
33
- [:evstr, [:call, [:str, "%.2f"], :%, [:arglist, [:lit, 3.14159]]]],
34
- [:str, "y"]]]
35
- end
24
+ [:block,
25
+ [:lasgn, :argl, [:lit, 1]],
26
+ [:dstr,
27
+ "x",
28
+ [:evstr, [:call, [:str, "%.2f"], :%, [:arglist, [:lit, 3.14159]]]],
29
+ [:str, "y"]]]
36
30
  end
37
31
 
38
- relates <<-ruby do
32
+ parse <<-ruby do
39
33
  max = 2
40
34
  argl = 1
41
35
  "x\#{("%.\#{max}f" % 3.14159)}y"
42
36
  ruby
43
37
 
44
- parse do
45
- [:block,
46
- [:lasgn, :max, [:lit, 2]],
47
- [:lasgn, :argl, [:lit, 1]],
48
- [:dstr,
49
- "x",
50
- [:evstr,
51
- [:call,
52
- [:dstr, "%.", [:evstr, [:lvar, :max]], [:str, "f"]],
53
- :%,
54
- [:arglist, [:lit, 3.14159]]]],
55
- [:str, "y"]]]
56
- end
38
+ [:block,
39
+ [:lasgn, :max, [:lit, 2]],
40
+ [:lasgn, :argl, [:lit, 1]],
41
+ [:dstr,
42
+ "x",
43
+ [:evstr,
44
+ [:call,
45
+ [:dstr, "%.", [:evstr, [:lvar, :max]], [:str, "f"]],
46
+ :%,
47
+ [:arglist, [:lit, 3.14159]]]],
48
+ [:str, "y"]]]
57
49
  end
58
50
 
59
- relates '"#{22}aa" "cd#{44}" "55" "#{66}"' do
60
- parse do
61
- [:dstr,
62
- "",
63
- [:evstr, [:lit, 22]],
64
- [:str, "aa"],
65
- [:str, "cd"],
66
- [:evstr, [:lit, 44]],
67
- [:str, "55"],
68
- [:evstr, [:lit, 66]]]
69
- end
51
+ parse '"#{22}aa" "cd#{44}" "55" "#{66}"' do
52
+ [:dstr,
53
+ "",
54
+ [:evstr, [:lit, 22]],
55
+ [:str, "aa"],
56
+ [:str, "cd"],
57
+ [:evstr, [:lit, 44]],
58
+ [:str, "55"],
59
+ [:evstr, [:lit, 66]]]
70
60
  end
71
61
 
72
- relates '"a #$global b #@ivar c #@@cvar d"' do
73
- parse do
74
- [:dstr,
75
- "a ",
76
- [:evstr, [:gvar, :$global]],
77
- [:str, " b "],
78
- [:evstr, [:ivar, :@ivar]],
79
- [:str, " c "],
80
- [:evstr, [:cvar, :@@cvar]],
81
- [:str, " d"]]
82
- end
62
+ parse '"a #$global b #@ivar c #@@cvar d"' do
63
+ [:dstr,
64
+ "a ",
65
+ [:evstr, [:gvar, :$global]],
66
+ [:str, " b "],
67
+ [:evstr, [:ivar, :@ivar]],
68
+ [:str, " c "],
69
+ [:evstr, [:cvar, :@@cvar]],
70
+ [:str, " d"]]
83
71
  end
84
72
 
85
- relates <<-ruby do
73
+ parse <<-ruby do
86
74
  <<EOM
87
75
  blah
88
76
  \#{1 + 1}blah
89
77
  EOM
90
78
  ruby
91
79
 
92
- parse do
93
- [:dstr,
94
- " blah\n",
95
- [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
96
- [:str, "blah\n"]]
97
- end
80
+ [:dstr,
81
+ " blah\n",
82
+ [:evstr, [:call, [:lit, 1], :+, [:arglist, [:lit, 1]]]],
83
+ [:str, "blah\n"]]
98
84
  end
99
85
 
100
- relates <<-ruby do
86
+ parse <<-ruby do
101
87
  <<-EOF
102
88
  def test_\#{action}_valid_feed
103
89
  EOF
104
90
  ruby
105
91
 
106
- parse do
107
- [:dstr,
108
- "def test_",
109
- [:evstr, [:call, nil, :action, [:arglist]]],
110
- [:str, "_valid_feed\n"]]
111
- end
92
+ [:dstr,
93
+ "def test_",
94
+ [:evstr, [:call, nil, :action, [:arglist]]],
95
+ [:str, "_valid_feed\n"]]
112
96
  end
113
97
 
114
- relates <<-ruby do
98
+ parse <<-ruby do
115
99
  <<-EOF
116
100
  s1 '\#{RUBY_PLATFORM}' s2
117
101
  \#{__FILE__}
118
102
  EOF
119
103
  ruby
120
104
 
121
- parse do
122
- [:dstr,
123
- "s1 '",
124
- [:evstr, [:const, :RUBY_PLATFORM]],
125
- [:str, "' s2\n"],
126
- [:evstr, [:file]],
127
- [:str, "\n"]]
128
- end
105
+ [:dstr,
106
+ "s1 '",
107
+ [:evstr, [:const, :RUBY_PLATFORM]],
108
+ [:str, "' s2\n"],
109
+ [:evstr, [:file]],
110
+ [:str, "\n"]]
129
111
  end
130
112
 
131
- relates "%Q[before [\#{nest}] after]" do
132
- parse do
133
- [:dstr,
134
- "before [",
135
- [:evstr, [:call, nil, :nest, [:arglist]]],
136
- [:str, "] after"]]
137
- end
113
+ parse "%Q[before [\#{nest}] after]" do
114
+ [:dstr,
115
+ "before [",
116
+ [:evstr, [:call, nil, :nest, [:arglist]]],
117
+ [:str, "] after"]]
138
118
  end
139
119
 
140
- relates '"#{"blah"}#{__FILE__}:#{__LINE__}: warning: #{$!.message} (#{$!.class})"' do
141
- parse do
142
- [:dstr,
143
- "blah",
144
- [:evstr, [:file]],
145
- [:str, ":"],
146
- [:evstr, [:lit, 1]],
147
- [:str, ": warning: "],
148
- [:evstr, [:call, [:gvar, :$!], :message, [:arglist]]],
149
- [:str, " ("],
150
- [:evstr, [:call, [:gvar, :$!], :class, [:arglist]]],
151
- [:str, ")"]]
152
- end
120
+ parse '"#{"blah"}#{__FILE__}:#{__LINE__}: warning: #{$!.message} (#{$!.class})"' do
121
+ [:dstr,
122
+ "blah",
123
+ [:evstr, [:file]],
124
+ [:str, ":"],
125
+ [:evstr, [:lit, 1]],
126
+ [:str, ": warning: "],
127
+ [:evstr, [:call, [:gvar, :$!], :message, [:arglist]]],
128
+ [:str, " ("],
129
+ [:evstr, [:call, [:gvar, :$!], :class, [:arglist]]],
130
+ [:str, ")"]]
153
131
  end
154
132
 
155
- relates '"before #{from} middle #{to} (#{__FILE__}:#{__LINE__})"' do
156
- parse do
157
- [:dstr,
158
- "before ",
159
- [:evstr, [:call, nil, :from, [:arglist]]],
160
- [:str, " middle "],
161
- [:evstr, [:call, nil, :to, [:arglist]]],
162
- [:str, " ("],
163
- [:evstr, [:file]],
164
- [:str, ":"],
165
- [:evstr, [:lit, 1]],
166
- [:str, ")"]]
167
- end
133
+ parse '"before #{from} middle #{to} (#{__FILE__}:#{__LINE__})"' do
134
+ [:dstr,
135
+ "before ",
136
+ [:evstr, [:call, nil, :from, [:arglist]]],
137
+ [:str, " middle "],
138
+ [:evstr, [:call, nil, :to, [:arglist]]],
139
+ [:str, " ("],
140
+ [:evstr, [:file]],
141
+ [:str, ":"],
142
+ [:evstr, [:lit, 1]],
143
+ [:str, ")"]]
168
144
  end
169
145
  end