Skip to content

Commit c7f7e7a

Browse files
hsbtclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 9dc2024 commit c7f7e7a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/console/color_test.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require_relative '../../lib/debug/color'
44
require_relative '../../lib/debug/config'
5+
require 'irb/version'
56
require 'test/unit'
67
require 'test/unit/rr'
78

@@ -33,7 +34,14 @@ def bar
3334
end
3435
end
3536

36-
{ "#{GREEN}#<struct #{CLEAR} #{CYAN}foo#{CLEAR}#{GREEN}=#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{RED}b#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}\n": dummy_class.new('b'),
37+
# IRB >= 1.18.0 highlights struct member names in cyan (ruby/irb#1189)
38+
if Gem::Version.new(IRB::VERSION) >= Gem::Version.new("1.18.0")
39+
struct_foo = "#{CYAN}foo#{CLEAR}"
40+
else
41+
struct_foo = "foo"
42+
end
43+
44+
{ "#{GREEN}#<struct #{CLEAR} #{struct_foo}#{GREEN}=#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{RED}b#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}#{GREEN}>#{CLEAR}\n": dummy_class.new('b'),
3745
"#{RED}#{BOLD}\"#{CLEAR}#{RED}hoge#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}\n": 'hoge'}.each do |k, v|
3846
expected = k.to_s
3947
obj = v

0 commit comments

Comments
 (0)