summaryrefslogtreecommitdiff
path: root/test/ripper/test_parser_events.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 13:38:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 13:38:17 +0000
commit577c03c7130e5776e0958d870e1aaf545d59e40e (patch)
tree9d8774fcf7fd764b527b3c2fb1079a2e4b1fd28b /test/ripper/test_parser_events.rb
parentce698d4c0d4eb9c48650466b7f1566c869eb2e01 (diff)
* parse.y (var_ref): distinguish vcall from local variable
references. based on a patch by Michael Edgar michael.j.edgar AT dartmouth.edu. Bug #5002 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper/test_parser_events.rb')
-rw-r--r--test/ripper/test_parser_events.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 14799d3..e6968e1 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -46,11 +46,15 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
end
def test_var_ref
- assert_equal '[ref(a)]', parse('a')
+ assert_equal '[assign(var_field(a),ref(a))]', parse('a=a')
assert_equal '[ref(nil)]', parse('nil')
assert_equal '[ref(true)]', parse('true')
end
+ def test_vcall
+ assert_equal '[vcall(a)]', parse('a')
+ end
+
def test_BEGIN
assert_equal '[BEGIN([void()])]', parse('BEGIN{}')
assert_equal '[BEGIN([ref(nil)])]', parse('BEGIN{nil}')
@@ -77,15 +81,15 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal '[fcall(m,[])]', parse('m()')
assert_equal '[fcall(m,[1])]', parse('m(1)')
assert_equal '[fcall(m,[1,2])]', parse('m(1,2)')
- assert_equal '[fcall(m,[*ref(r)])]', parse('m(*r)')
- assert_equal '[fcall(m,[1,*ref(r)])]', parse('m(1,*r)')
- assert_equal '[fcall(m,[1,2,*ref(r)])]', parse('m(1,2,*r)')
- assert_equal '[fcall(m,[&ref(r)])]', parse('m(&r)')
- assert_equal '[fcall(m,[1,&ref(r)])]', parse('m(1,&r)')
- assert_equal '[fcall(m,[1,2,&ref(r)])]', parse('m(1,2,&r)')
- assert_equal '[fcall(m,[*ref(a),&ref(b)])]', parse('m(*a,&b)')
- assert_equal '[fcall(m,[1,*ref(a),&ref(b)])]', parse('m(1,*a,&b)')
- assert_equal '[fcall(m,[1,2,*ref(a),&ref(b)])]', parse('m(1,2,*a,&b)')
+ assert_equal '[fcall(m,[*vcall(r)])]', parse('m(*r)')
+ assert_equal '[fcall(m,[1,*vcall(r)])]', parse('m(1,*r)')
+ assert_equal '[fcall(m,[1,2,*vcall(r)])]', parse('m(1,2,*r)')
+ assert_equal '[fcall(m,[&vcall(r)])]', parse('m(&r)')
+ assert_equal '[fcall(m,[1,&vcall(r)])]', parse('m(1,&r)')
+ assert_equal '[fcall(m,[1,2,&vcall(r)])]', parse('m(1,2,&r)')
+ assert_equal '[fcall(m,[*vcall(a),&vcall(b)])]', parse('m(*a,&b)')
+ assert_equal '[fcall(m,[1,*vcall(a),&vcall(b)])]', parse('m(1,*a,&b)')
+ assert_equal '[fcall(m,[1,2,*vcall(a),&vcall(b)])]', parse('m(1,2,*a,&b)')
end
def test_args_add
@@ -120,8 +124,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
end
def test_aref
- assert_equal '[aref(ref(v),[1])]', parse('v[1]')
- assert_equal '[aref(ref(v),[1,2])]', parse('v[1,2]')
+ assert_equal '[aref(vcall(v),[1])]', parse('v[1]')
+ assert_equal '[aref(vcall(v),[1,2])]', parse('v[1,2]')
end
def test_assoclist_from_args
@@ -143,7 +147,7 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
end
def test_aref_field
- assert_equal '[assign(aref_field(ref(a),[1]),2)]', parse('a[1]=2')
+ assert_equal '[assign(aref_field(vcall(a),[1]),2)]', parse('a[1]=2')
end
def test_arg_ambiguous
@@ -323,7 +327,7 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
tree = parse("foo.()", :on_call) {thru_call = true}
}
assert_equal true, thru_call
- assert_equal "[call(ref(foo),.,call,[])]", tree
+ assert_equal "[call(vcall(foo),.,call,[])]", tree
end
def test_excessed_comma