mirror of
https://github.com/ruby/ruby.git
synced 2025-09-24 04:54:01 +02:00
Suppress constant redefinition warnings
This commit is contained in:
parent
c63552eab1
commit
480f436dac
3 changed files with 9 additions and 1 deletions
|
@ -153,13 +153,15 @@ module TestIRB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IRBTestColorPrinter = Struct.new(:a)
|
||||||
|
|
||||||
def test_color_printer
|
def test_color_printer
|
||||||
unless ripper_lexer_scan_supported?
|
unless ripper_lexer_scan_supported?
|
||||||
skip 'Ripper::Lexer#scan is supported in Ruby 2.7+'
|
skip 'Ripper::Lexer#scan is supported in Ruby 2.7+'
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
1 => "#{BLUE}#{BOLD}1#{CLEAR}\n",
|
1 => "#{BLUE}#{BOLD}1#{CLEAR}\n",
|
||||||
Struct.new('IRBTestColorPrinter', :a).new('test') => "#{GREEN}#<struct Struct::IRBTestColorPrinter#{CLEAR} a#{GREEN}=#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{RED}test#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}\n",
|
IRBTestColorPrinter.new('test') => "#{GREEN}#<struct TestIRB::TestColor::IRBTestColorPrinter#{CLEAR} a#{GREEN}=#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{RED}test#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}\n",
|
||||||
Ripper::Lexer.new('1').scan => "[#{GREEN}#<Ripper::Lexer::Elem:#{CLEAR} on_int@1:0 END token: #{RED}#{BOLD}\"#{CLEAR}#{RED}1#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}]\n",
|
Ripper::Lexer.new('1').scan => "[#{GREEN}#<Ripper::Lexer::Elem:#{CLEAR} on_int@1:0 END token: #{RED}#{BOLD}\"#{CLEAR}#{RED}1#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}]\n",
|
||||||
}.each do |object, result|
|
}.each do |object, result|
|
||||||
actual = with_term { IRB::ColorPrinter.pp(object, '') }
|
actual = with_term { IRB::ColorPrinter.pp(object, '') }
|
||||||
|
|
|
@ -58,6 +58,8 @@ class TestMarshal < Test::Unit::TestCase
|
||||||
TestMarshal.instance_eval { remove_const :StructOrNot }
|
TestMarshal.instance_eval { remove_const :StructOrNot }
|
||||||
TestMarshal.const_set :StructOrNot, Class.new
|
TestMarshal.const_set :StructOrNot, Class.new
|
||||||
assert_raise(TypeError, "[ruby-dev:31709]") { Marshal.load(s) }
|
assert_raise(TypeError, "[ruby-dev:31709]") { Marshal.load(s) }
|
||||||
|
ensure
|
||||||
|
TestMarshal.instance_eval { remove_const :StructOrNot }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_struct_invalid_members
|
def test_struct_invalid_members
|
||||||
|
@ -66,6 +68,8 @@ class TestMarshal < Test::Unit::TestCase
|
||||||
Marshal.load("\004\bIc&TestMarshal::StructInvalidMembers\006:\020__members__\"\bfoo")
|
Marshal.load("\004\bIc&TestMarshal::StructInvalidMembers\006:\020__members__\"\bfoo")
|
||||||
TestMarshal::StructInvalidMembers.members
|
TestMarshal::StructInvalidMembers.members
|
||||||
}
|
}
|
||||||
|
ensure
|
||||||
|
TestMarshal.instance_eval { remove_const :StructInvalidMembers }
|
||||||
end
|
end
|
||||||
|
|
||||||
class C
|
class C
|
||||||
|
|
|
@ -793,6 +793,8 @@ class TestModule < Test::Unit::TestCase
|
||||||
assert_equal(prefix+"C", m.const_get(:C).name)
|
assert_equal(prefix+"C", m.const_get(:C).name)
|
||||||
c = m.class_eval("Bug15891 = Class.new.freeze")
|
c = m.class_eval("Bug15891 = Class.new.freeze")
|
||||||
assert_equal(prefix+"Bug15891", c.name)
|
assert_equal(prefix+"Bug15891", c.name)
|
||||||
|
ensure
|
||||||
|
self.class.class_eval {remove_const(:M)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_private_class_method
|
def test_private_class_method
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue