ruby-changes:56294
From: Nobuyoshi <ko1@a...>
Date: Sun, 30 Jun 2019 20:23:50 +0900 (JST)
Subject: [ruby-changes:56294] Nobuyoshi Nakada: 3620568d3a (trunk): Suppress void context warnings in verbose mode
https://git.ruby-lang.org/ruby.git/commit/?id=3620568d3a From 3620568d3ac0533b050985d7c3c4ca871d464fd6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 30 Jun 2019 09:51:09 +0900 Subject: Suppress void context warnings in verbose mode diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 9598aa7..aca9313 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -130,6 +130,12 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L130 end end + private def parse(src) + EnvUtil.suppress_warning { + RubyVM::AbstractSyntaxTree.parse(src) + } + end + def test_allocate assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate} end @@ -144,19 +150,19 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L150 def test_column_with_long_heredoc_identifier term = "A"*257 - ast = RubyVM::AbstractSyntaxTree.parse("<<-#{term}\n""ddddddd\n#{term}\n") + ast = parse("<<-#{term}\n""ddddddd\n#{term}\n") node = ast.children[2] assert_equal(:STR, node.type) assert_equal(0, node.first_column) end def test_column_of_heredoc - node = RubyVM::AbstractSyntaxTree.parse("<<-SRC\nddddddd\nSRC\n").children[2] + node = parse("<<-SRC\nddddddd\nSRC\n").children[2] assert_equal(:STR, node.type) assert_equal(0, node.first_column) assert_equal(6, node.last_column) - node = RubyVM::AbstractSyntaxTree.parse("<<SRC\nddddddd\nSRC\n").children[2] + node = parse("<<SRC\nddddddd\nSRC\n").children[2] assert_equal(:STR, node.type) assert_equal(0, node.first_column) assert_equal(5, node.last_column) @@ -268,7 +274,7 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L274 end def test_dstr - node = RubyVM::AbstractSyntaxTree.parse('"foo#{1}bar"') + node = parse('"foo#{1}bar"') _, _, body = *node.children assert_equal(:DSTR, body.type) head, body = body.children diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index f7cbc76..afd5d20 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -256,8 +256,8 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L256 def assert_syntax_error_backtrace Dir.mktmpdir do |tmp| req = File.join(tmp, "test.rb") - File.write(req, "'\n") - e = assert_raise_with_message(SyntaxError, /unterminated/) { + File.write(req, ",\n") + e = assert_raise_with_message(SyntaxError, /unexpected/) { yield req } assert_not_nil(bt = e.backtrace) diff --git a/test/test_pp.rb b/test/test_pp.rb index d010465..4736bff 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -196,9 +196,9 @@ end https://github.com/ruby/ruby/blob/trunk/test/test_pp.rb#L196 class PPAbstractSyntaxTree < Test::Unit::TestCase AST = RubyVM::AbstractSyntaxTree - def test_literal - ast = AST.parse("1") - expected = "(SCOPE@1:0-1:1 tbl: [] args: nil body: (LIT@1:0-1:1 1))" + def test_lasgn_literal + ast = AST.parse("_=1") + expected = "(SCOPE@1:0-1:3 tbl: [:_] args: nil body: (LASGN@1:0-1:3 :_ (LIT@1:2-1:3 1)))" assert_equal(expected, PP.singleline_pp(ast, ''.dup), ast) end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/