[ruby/irb] Test colors with enabling colors

https://github.com/ruby/irb/commit/998b7a74fa
This commit is contained in:
Nobuyoshi Nakada 2022-12-27 00:01:46 +09:00 коммит произвёл git
Родитель d93d786338
Коммит a968d783a3
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -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"
{

Просмотреть файл

@ -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)