aboutsummaryrefslogtreecommitdiffstats
path: root/test/irb/test_color.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/irb/test_color.rb')
-rw-r--r--test/irb/test_color.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 4b1878545e..8439fd54f5 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -15,6 +15,11 @@ module TestIRB
CYAN = "\e[36m"
def test_colorize_code
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0')
+ assert_equal({}, IRB::Color::TOKEN_SEQ_EXPRS)
+ skip "this Ripper version is not supported"
+ end
+
{
"1" => "#{BLUE}#{BOLD}1#{CLEAR}",
"2.3" => "#{MAGENTA}#{BOLD}2.3#{CLEAR}",
@@ -23,11 +28,22 @@ module TestIRB
"def self.foo; bar; end" => "#{GREEN}def#{CLEAR} #{CYAN}#{BOLD}self#{CLEAR}.#{BLUE}#{BOLD}foo#{CLEAR}; bar; #{GREEN}end#{CLEAR}",
'ERB.new("a#{nil}b", trim_mode: "-")' => "#{BLUE}#{BOLD}#{UNDERLINE}ERB#{CLEAR}.new(#{RED}\"#{CLEAR}#{RED}a#{CLEAR}#{RED}\#{#{CLEAR}#{CYAN}#{BOLD}nil#{CLEAR}#{RED}}#{CLEAR}#{RED}b#{CLEAR}#{RED}\"#{CLEAR}, #{MAGENTA}trim_mode:#{CLEAR} #{RED}\"#{CLEAR}#{RED}-#{CLEAR}#{RED}\"#{CLEAR})",
"# comment" => "#{BLUE}#{BOLD}# comment#{CLEAR}",
- '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}",
"yield(hello)" => "#{GREEN}yield#{CLEAR}(hello)",
}.each do |code, result|
assert_equal(result, with_term { IRB::Color.colorize_code(code) })
end
+
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
+ {
+ '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}",
+ }
+ else
+ {
+ '/r#{e}g/' => "#{RED}#{BOLD}/#{CLEAR}#{RED}r#{CLEAR}#{RED}\#{#{CLEAR}e#{RED}}#{CLEAR}#{RED}g#{CLEAR}#{RED}#{BOLD}/#{CLEAR}",
+ }
+ end.each do |code, result|
+ assert_equal(result, with_term { IRB::Color.colorize_code(code) })
+ end
end
def test_inspect_colorable