mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Suppress void context warnings in verbose mode
This commit is contained in:
parent
c400c0b4a0
commit
3620568d3a
3 changed files with 15 additions and 9 deletions
|
@ -130,6 +130,12 @@ class TestAst < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def parse(src)
|
||||||
|
EnvUtil.suppress_warning {
|
||||||
|
RubyVM::AbstractSyntaxTree.parse(src)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_allocate
|
def test_allocate
|
||||||
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate}
|
assert_raise(TypeError) {RubyVM::AbstractSyntaxTree::Node.allocate}
|
||||||
end
|
end
|
||||||
|
@ -144,19 +150,19 @@ class TestAst < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_column_with_long_heredoc_identifier
|
def test_column_with_long_heredoc_identifier
|
||||||
term = "A"*257
|
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]
|
node = ast.children[2]
|
||||||
assert_equal(:STR, node.type)
|
assert_equal(:STR, node.type)
|
||||||
assert_equal(0, node.first_column)
|
assert_equal(0, node.first_column)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_column_of_heredoc
|
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(:STR, node.type)
|
||||||
assert_equal(0, node.first_column)
|
assert_equal(0, node.first_column)
|
||||||
assert_equal(6, node.last_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(:STR, node.type)
|
||||||
assert_equal(0, node.first_column)
|
assert_equal(0, node.first_column)
|
||||||
assert_equal(5, node.last_column)
|
assert_equal(5, node.last_column)
|
||||||
|
@ -268,7 +274,7 @@ class TestAst < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dstr
|
def test_dstr
|
||||||
node = RubyVM::AbstractSyntaxTree.parse('"foo#{1}bar"')
|
node = parse('"foo#{1}bar"')
|
||||||
_, _, body = *node.children
|
_, _, body = *node.children
|
||||||
assert_equal(:DSTR, body.type)
|
assert_equal(:DSTR, body.type)
|
||||||
head, body = body.children
|
head, body = body.children
|
||||||
|
|
|
@ -256,8 +256,8 @@ class TestRequire < Test::Unit::TestCase
|
||||||
def assert_syntax_error_backtrace
|
def assert_syntax_error_backtrace
|
||||||
Dir.mktmpdir do |tmp|
|
Dir.mktmpdir do |tmp|
|
||||||
req = File.join(tmp, "test.rb")
|
req = File.join(tmp, "test.rb")
|
||||||
File.write(req, "'\n")
|
File.write(req, ",\n")
|
||||||
e = assert_raise_with_message(SyntaxError, /unterminated/) {
|
e = assert_raise_with_message(SyntaxError, /unexpected/) {
|
||||||
yield req
|
yield req
|
||||||
}
|
}
|
||||||
assert_not_nil(bt = e.backtrace)
|
assert_not_nil(bt = e.backtrace)
|
||||||
|
|
|
@ -196,9 +196,9 @@ end
|
||||||
|
|
||||||
class PPAbstractSyntaxTree < Test::Unit::TestCase
|
class PPAbstractSyntaxTree < Test::Unit::TestCase
|
||||||
AST = RubyVM::AbstractSyntaxTree
|
AST = RubyVM::AbstractSyntaxTree
|
||||||
def test_literal
|
def test_lasgn_literal
|
||||||
ast = AST.parse("1")
|
ast = AST.parse("_=1")
|
||||||
expected = "(SCOPE@1:0-1:1 tbl: [] args: nil body: (LIT@1:0-1:1 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)
|
assert_equal(expected, PP.singleline_pp(ast, ''.dup), ast)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue