зеркало из https://github.com/github/ruby.git
Stop using global constant, RELINE_TEST_ENCODING
This commit is contained in:
Родитель
af19f9a6e9
Коммит
1192393b3e
|
@ -7,7 +7,11 @@ module Reline
|
|||
def test_mode
|
||||
remove_const('IOGate') if const_defined?('IOGate')
|
||||
const_set('IOGate', Reline::GeneralIO)
|
||||
encoding = (RELINE_TEST_ENCODING rescue nil)
|
||||
if ENV['RELINE_TEST_ENCODING']
|
||||
encoding = Encoding.find(ENV['RELINE_TEST_ENCODING'])
|
||||
else
|
||||
encoding = Encoding::UTF_8
|
||||
end
|
||||
Reline::GeneralIO.reset(encoding: encoding)
|
||||
send(:core).config.instance_variable_set(:@test_mode, true)
|
||||
send(:core).config.reset
|
||||
|
@ -27,13 +31,6 @@ def finish_pasting
|
|||
Reline::GeneralIO.finish_pasting
|
||||
end
|
||||
|
||||
RELINE_TEST_ENCODING ||=
|
||||
if ENV['RELINE_TEST_ENCODING']
|
||||
Encoding.find(ENV['RELINE_TEST_ENCODING'])
|
||||
else
|
||||
Encoding::UTF_8
|
||||
end
|
||||
|
||||
class Reline::TestCase < Test::Unit::TestCase
|
||||
private def convert_str(input, options = {}, normalized = nil)
|
||||
return nil if input.nil?
|
||||
|
|
|
@ -296,7 +296,7 @@ class Reline::History::Test < Reline::TestCase
|
|||
end
|
||||
|
||||
def get_default_internal_encoding
|
||||
if encoding = (RELINE_TEST_ENCODING rescue nil)
|
||||
if encoding = Reline::IOGate.encoding
|
||||
encoding
|
||||
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
||||
Encoding.default_internal || Encoding::UTF_8
|
||||
|
|
|
@ -7,7 +7,7 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
@config = Reline::Config.new # Emacs mode is default
|
||||
Reline::HISTORY.instance_variable_set(:@config, @config)
|
||||
Reline::HISTORY.clear
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@encoding = Reline::IOGate.encoding
|
||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||
@line_editor.reset(@prompt, encoding: @encoding)
|
||||
end
|
||||
|
@ -2140,7 +2140,7 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
end
|
||||
|
||||
# Unicode emoji test
|
||||
if RELINE_TEST_ENCODING == Encoding::UTF_8
|
||||
if Reline::IOGate.encoding == Encoding::UTF_8
|
||||
def test_ed_insert_for_include_zwj_emoji
|
||||
# U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466 is family: man, woman, girl, boy "👨👩👧👦"
|
||||
input_keys("\u{1F468}") # U+1F468 is man "👨"
|
||||
|
|
|
@ -8,7 +8,7 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
|||
@config.read_lines(<<~LINES.split(/(?<=\n)/))
|
||||
set editing-mode vi
|
||||
LINES
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@encoding = Reline::IOGate.encoding
|
||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||
@line_editor.reset(@prompt, encoding: @encoding)
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class Reline::MacroTest < Reline::TestCase
|
|||
def setup
|
||||
Reline.send(:test_mode)
|
||||
@config = Reline::Config.new
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@encoding = Reline::IOGate.encoding
|
||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||
@line_editor.instance_variable_set(:@screen_size, [24, 80])
|
||||
@output = @line_editor.output = File.open(IO::NULL, "w")
|
||||
|
|
|
@ -314,7 +314,7 @@ class Reline::Test < Reline::TestCase
|
|||
end
|
||||
|
||||
def get_reline_encoding
|
||||
if encoding = (RELINE_TEST_ENCODING rescue nil)
|
||||
if encoding = Reline::IOGate.encoding
|
||||
encoding
|
||||
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
||||
Encoding::UTF_8
|
||||
|
|
|
@ -6,7 +6,7 @@ class Reline::LineEditor::StringProcessingTest < Reline::TestCase
|
|||
@prompt = '> '
|
||||
@config = Reline::Config.new
|
||||
Reline::HISTORY.instance_variable_set(:@config, @config)
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@encoding = Reline::IOGate.encoding
|
||||
@line_editor = Reline::LineEditor.new(@config, @encoding)
|
||||
@line_editor.reset(@prompt, encoding: @encoding)
|
||||
end
|
||||
|
|
|
@ -3,9 +3,10 @@ require_relative 'helper'
|
|||
class Reline::WithinPipeTest < Reline::TestCase
|
||||
def setup
|
||||
Reline.send(:test_mode)
|
||||
@input_reader, @writer = IO.pipe((RELINE_TEST_ENCODING rescue Encoding.default_external))
|
||||
@encoding = Reline::IOGate.encoding
|
||||
@input_reader, @writer = IO.pipe(@encoding)
|
||||
Reline.input = @input_reader
|
||||
@reader, @output_writer = IO.pipe((RELINE_TEST_ENCODING rescue Encoding.default_external))
|
||||
@reader, @output_writer = IO.pipe(@encoding)
|
||||
@output = Reline.output = @output_writer
|
||||
@config = Reline.send(:core).config
|
||||
@config.keyseq_timeout *= 600 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # for --jit-wait CI
|
||||
|
|
Загрузка…
Ссылка в новой задаче