mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Suppress warnings when testing RubyVM::AbstractSyntaxTree
This commit is contained in:
parent
1902c42b1f
commit
af210467b5
@ -48,7 +48,7 @@ class TestAst < Test::Unit::TestCase
|
||||
@path = path
|
||||
@errors = []
|
||||
@debug = false
|
||||
@ast = RubyVM::AbstractSyntaxTree.parse(src) if src
|
||||
@ast = EnvUtil.suppress_warning { RubyVM::AbstractSyntaxTree.parse(src) } if src
|
||||
end
|
||||
|
||||
def validate_range
|
||||
@ -67,7 +67,7 @@ class TestAst < Test::Unit::TestCase
|
||||
|
||||
def ast
|
||||
return @ast if defined?(@ast)
|
||||
@ast = RubyVM::AbstractSyntaxTree.parse_file(@path)
|
||||
@ast = EnvUtil.suppress_warning { RubyVM::AbstractSyntaxTree.parse_file(@path) }
|
||||
end
|
||||
|
||||
private
|
||||
@ -135,7 +135,7 @@ class TestAst < Test::Unit::TestCase
|
||||
|
||||
Dir.glob("test/**/*.rb", base: SRCDIR).each do |path|
|
||||
define_method("test_all_tokens:#{path}") do
|
||||
node = RubyVM::AbstractSyntaxTree.parse_file("#{SRCDIR}/#{path}", keep_tokens: true)
|
||||
node = EnvUtil.suppress_warning { RubyVM::AbstractSyntaxTree.parse_file("#{SRCDIR}/#{path}", keep_tokens: true) }
|
||||
tokens = node.all_tokens.sort_by { [_1.last[0], _1.last[1]] }
|
||||
tokens_bytes = tokens.map { _1[2]}.join.bytes
|
||||
source_bytes = File.read("#{SRCDIR}/#{path}").bytes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user