From c7f7e7a7f8bc55567c0093f55293b78ac9897be4 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 14 Apr 2026 13:28:04 +0900 Subject: [PATCH] Adapt color test expectation for IRB >= 1.18.0 IRB 1.18.0 (ruby/irb#1189) highlights struct member names in cyan. Branch the expected value by IRB version so the test passes with both old and new IRB. Co-Authored-By: Claude Opus 4.6 (1M context) --- test/console/color_test.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/console/color_test.rb b/test/console/color_test.rb index cb3fef1cb..ea27d433a 100644 --- a/test/console/color_test.rb +++ b/test/console/color_test.rb @@ -2,6 +2,7 @@ require_relative '../../lib/debug/color' require_relative '../../lib/debug/config' +require 'irb/version' require 'test/unit' require 'test/unit/rr' @@ -33,7 +34,14 @@ def bar end end - { "#{GREEN}##{CLEAR}\n": dummy_class.new('b'), + # IRB >= 1.18.0 highlights struct member names in cyan (ruby/irb#1189) + if Gem::Version.new(IRB::VERSION) >= Gem::Version.new("1.18.0") + struct_foo = "#{CYAN}foo#{CLEAR}" + else + struct_foo = "foo" + end + + { "#{GREEN}##{CLEAR}\n": dummy_class.new('b'), "#{RED}#{BOLD}\"#{CLEAR}#{RED}hoge#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}\n": 'hoge'}.each do |k, v| expected = k.to_s obj = v