summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-12-27 00:01:46 +0900
committergit <svn-admin@ruby-lang.org>2022-12-26 15:28:38 +0000
commita968d783a3dbd3585b6285c5c9c9ef11bd36b6f4 (patch)
tree597485701b92c2e14ef0127c5abab2e5d17b8fa2
parentd93d786338b3dca54595a6619f433607a834816a (diff)
[ruby/irb] Test colors with enabling colors
https://github.com/ruby/irb/commit/998b7a74fa
-rw-r--r--test/irb/test_color.rb14
-rw-r--r--test/irb/test_color_printer.rb8
2 files changed, 22 insertions, 0 deletions
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 1b27afb898..ca4ae4b8f9 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -18,6 +18,20 @@ module TestIRB
MAGENTA = "\e[35m"
CYAN = "\e[36m"
+ def setup
+ super
+ if IRB.respond_to?(:conf)
+ @colorize, IRB.conf[:USE_COLORIZE] = IRB.conf[:USE_COLORIZE], true
+ end
+ end
+
+ def teardown
+ if instance_variable_defined?(:@colorize)
+ IRB.conf[:USE_COLORIZE] = @colorize
+ end
+ super
+ end
+
def test_colorize
text = "text"
{
diff --git a/test/irb/test_color_printer.rb b/test/irb/test_color_printer.rb
index 79ab050550..41a7345bd3 100644
--- a/test/irb/test_color_printer.rb
+++ b/test/irb/test_color_printer.rb
@@ -15,6 +15,10 @@ module TestIRB
CYAN = "\e[36m"
def setup
+ super
+ if IRB.respond_to?(:conf)
+ @colorize, IRB.conf[:USE_COLORIZE] = IRB.conf[:USE_COLORIZE], true
+ end
@get_screen_size = Reline.method(:get_screen_size)
Reline.instance_eval { undef :get_screen_size }
def Reline.get_screen_size
@@ -25,6 +29,10 @@ module TestIRB
def teardown
Reline.instance_eval { undef :get_screen_size }
Reline.define_singleton_method(:get_screen_size, @get_screen_size)
+ if instance_variable_defined?(:@colorize)
+ IRB.conf[:USE_COLORIZE] = @colorize
+ end
+ super
end
IRBTestColorPrinter = Struct.new(:a)