summaryrefslogtreecommitdiff
path: root/test/irb/test_color.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-11 00:33:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-11 00:33:26 +0900
commit480f436dacc28def6c23d6b914f03ac6a0753d5d (patch)
treea64fe0c1bdc609623cd20df200bb1eca67b43f62 /test/irb/test_color.rb
parentc63552eab1a13c6c05e18d763c7acf3c4c5383ed (diff)
Suppress constant redefinition warnings
Diffstat (limited to 'test/irb/test_color.rb')
-rw-r--r--test/irb/test_color.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 203b605296..b136d38165 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -153,13 +153,15 @@ module TestIRB
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, '') }