From fa409e6cbb4168b717f9cbbcae29435d31ccc6cc Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 8 Jun 2018 11:03:39 +0000 Subject: ast.c: fix calls * ast.c (node_children): fix the member for method IDs as nd_mid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_ast.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 90c06fb5ce..5659cac6b0 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -178,4 +178,32 @@ class TestAst < Test::Unit::TestCase assert_equal([:x], lv) assert_equal("NODE_LASGN", body.type) end + + def test_call + node = RubyVM::AST.parse("nil.foo") + _, _, body = *node.children + assert_equal("NODE_CALL", body.type) + recv, mid, args = body.children + assert_equal("NODE_NIL", recv.type) + assert_equal(:foo, mid) + assert_nil(args) + end + + def test_fcall + node = RubyVM::AST.parse("foo()") + _, _, body = *node.children + assert_equal("NODE_FCALL", body.type) + mid, args = body.children + assert_equal(:foo, mid) + assert_nil(args) + end + + def test_vcall + node = RubyVM::AST.parse("foo") + _, _, body = *node.children + assert_equal("NODE_VCALL", body.type) + mid, args = body.children + assert_equal(:foo, mid) + assert_nil(args) + end end -- cgit v1.2.3