diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-01 14:41:51 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-01 14:45:00 +0900 |
commit | 1e51027763ab2b96e9a1a0aecbe7d42e62d00fc6 (patch) | |
tree | 8586f5153737f9049c48b171fd42e20903420981 /test/ruby/test_ast.rb | |
parent | de5f8a92d5001799bedb3b1a271a2d9b23c6c8fb (diff) |
Added AST tests for endless method definitions
Diffstat (limited to 'test/ruby/test_ast.rb')
-rw-r--r-- | test/ruby/test_ast.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 0d846b76e4..9c218f3ad8 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -255,6 +255,15 @@ class TestAst < Test::Unit::TestCase assert_equal(:SCOPE, defn.type) end + def test_defn_endless + node = RubyVM::AbstractSyntaxTree.parse("def a = nil") + _, _, body = *node.children + assert_equal(:DEFN, body.type) + mid, defn = body.children + assert_equal(:a, mid) + assert_equal(:SCOPE, defn.type) + end + def test_defs node = RubyVM::AbstractSyntaxTree.parse("def a.b; end") _, _, body = *node.children @@ -265,6 +274,16 @@ class TestAst < Test::Unit::TestCase assert_equal(:SCOPE, defn.type) end + def test_defs_endless + node = RubyVM::AbstractSyntaxTree.parse("def a.b = nil") + _, _, body = *node.children + assert_equal(:DEFS, body.type) + recv, mid, defn = body.children + assert_equal(:VCALL, recv.type) + assert_equal(:b, mid) + assert_equal(:SCOPE, defn.type) + end + def test_dstr node = parse('"foo#{1}bar"') _, _, body = *node.children |