ruby-changes:64820
From: Nobuyoshi <ko1@a...>
Date: Mon, 11 Jan 2021 00:47:35 +0900 (JST)
Subject: [ruby-changes:64820] 480f436dac (master): Suppress constant redefinition warnings
https://git.ruby-lang.org/ruby.git/commit/?id=480f436dac From 480f436dacc28def6c23d6b914f03ac6a0753d5d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 11 Jan 2021 00:33:26 +0900 Subject: Suppress constant redefinition warnings diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index 203b605..b136d38 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -153,13 +153,15 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L153 end end + IRBTestColorPrinter = Struct.new(:a) + def test_color_printer unless ripper_lexer_scan_supported? skip 'Ripper::Lexer#scan is supported in Ruby 2.7+' end { 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", }.each do |object, result| actual = with_term { IRB::ColorPrinter.pp(object, '') } diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index ef8b261..d2b4ec1 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -58,6 +58,8 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L58 TestMarshal.instance_eval { remove_const :StructOrNot } TestMarshal.const_set :StructOrNot, Class.new assert_raise(TypeError, "[ruby-dev:31709]") { Marshal.load(s) } + ensure + TestMarshal.instance_eval { remove_const :StructOrNot } end def test_struct_invalid_members @@ -66,6 +68,8 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L68 Marshal.load("\004\bIc&TestMarshal::StructInvalidMembers\006:\020__members__\"\bfoo") TestMarshal::StructInvalidMembers.members } + ensure + TestMarshal.instance_eval { remove_const :StructInvalidMembers } end class C diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 43f0c51..fac3131 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -793,6 +793,8 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L793 assert_equal(prefix+"C", m.const_get(:C).name) c = m.class_eval("Bug15891 = Class.new.freeze") assert_equal(prefix+"Bug15891", c.name) + ensure + self.class.class_eval {remove_const(:M)} end def test_private_class_method -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/