ruby-changes:64697
From: Nobuyoshi <ko1@a...>
Date: Fri, 1 Jan 2021 14:50:10 +0900 (JST)
Subject: [ruby-changes:64697] 1e51027763 (master): Added AST tests for endless method definitions
https://git.ruby-lang.org/ruby.git/commit/?id=1e51027763 From 1e51027763ab2b96e9a1a0aecbe7d42e62d00fc6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 1 Jan 2021 14:41:51 +0900 Subject: Added AST tests for endless method definitions diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 0d846b7..9c218f3 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -255,6 +255,15 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L255 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L274 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/