summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-30 09:51:09 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-30 11:49:40 +0900
commit3620568d3ac0533b050985d7c3c4ca871d464fd6 (patch)
treeac24bfba224e8c5b0db57e53811486a7adbc3239
parentc400c0b4a00706a0da33664c1898e15f1aba0eec (diff)
Suppress void context warnings in verbose mode
-rw-r--r--test/ruby/test_ast.rb14
-rw-r--r--test/ruby/test_require.rb4
-rw-r--r--test/test_pp.rb6
3 files changed, 15 insertions, 9 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 9598aa7553..aca9313529 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -130,6 +130,12 @@ class TestAst < Test::Unit::TestCase
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
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
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 f7cbc76a6e..afd5d20558 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -256,8 +256,8 @@ class TestRequire < Test::Unit::TestCase
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 d0104651ea..4736bff149 100644
--- a/test/test_pp.rb
+++ b/test/test_pp.rb
@@ -196,9 +196,9 @@ end
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