From 63e72a5850e2789920da6bc43169d74ccb0fa66c Mon Sep 17 00:00:00 2001 From: yui-knk Date: Thu, 28 Jun 2018 14:33:28 +0000 Subject: ast.c: Fix defs * ast.c (node_children): Add mid to children git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_ast.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby/test_ast.rb') diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index cbc3231dd3..f59b54c17a 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -204,4 +204,23 @@ class TestAst < Test::Unit::TestCase assert_equal(:foo, mid) assert_nil(args) end + + def test_defn + node = RubyVM::AST.parse("def a; end") + _, _, body = *node.children + assert_equal("NODE_DEFN", body.type) + mid, defn = body.children + assert_equal(:a, mid) + assert_equal("NODE_SCOPE", defn.type) + end + + def test_defs + node = RubyVM::AST.parse("def a.b; end") + _, _, body = *node.children + assert_equal("NODE_DEFS", body.type) + recv, mid, defn = body.children + assert_equal("NODE_VCALL", recv.type) + assert_equal(:b, mid) + assert_equal("NODE_SCOPE", defn.type) + end end -- cgit v1.2.3