diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-05 02:13:45 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-05 02:13:45 +0000 |
commit | ce798d08de38a89852017bfefe44708b97121d74 (patch) | |
tree | f15bcecacdd4f2cd8a5b3890d77fa1c83f5440a6 /test/ruby/test_ast.rb | |
parent | 6d497629b22f67bcaa4d074e0bee728808cfd4be (diff) |
Implement `RubyVM::AST.of` [Feature #14836]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_ast.rb')
-rw-r--r-- | test/ruby/test_ast.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index d053ce5a49..70f0b4af1f 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -170,6 +170,18 @@ class TestAst < Test::Unit::TestCase end end + def test_of + proc = Proc.new { 1 + 2 } + method = self.method(__method__) + + node_proc = RubyVM::AST.of(proc) + node_method = RubyVM::AST.of(method) + + assert_instance_of(RubyVM::AST::Node, node_proc) + assert_instance_of(RubyVM::AST::Node, node_method) + assert_raise(TypeError) { RubyVM::AST.of("1 + 2") } + end + def test_scope_local_variables node = RubyVM::AST.parse("x = 0") lv, _, body = *node.children |