Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/irb/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

module TestIRB
class TestCase < Test::Unit::TestCase
class TestInputMethod < ::IRB::InputMethod
attr_reader :list, :line_no

def initialize(list = [])
super("test")
@line_no = 0
@list = list
end

def gets
@list[@line_no]&.tap {@line_no += 1}
end

def eof?
@line_no >= @list.size
end

def encoding
Encoding.default_external
end

def reset
@line_no = 0
end
end

def save_encodings
@default_encoding = [Encoding.default_external, Encoding.default_internal]
@stdio_encodings = [STDIN, STDOUT, STDERR].map {|io| [io.external_encoding, io.internal_encoding] }
Expand Down
26 changes: 0 additions & 26 deletions test/irb/test_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,6 @@

module TestIRB
class ExtendCommandTest < TestCase
class TestInputMethod < ::IRB::InputMethod
attr_reader :list, :line_no

def initialize(list = [])
super("test")
@line_no = 0
@list = list
end

def gets
@list[@line_no]&.tap {@line_no += 1}
end

def eof?
@line_no >= @list.size
end

def encoding
Encoding.default_external
end

def reset
@line_no = 0
end
end

def setup
@pwd = Dir.pwd
@tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}")
Expand Down
26 changes: 0 additions & 26 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,6 @@

module TestIRB
class TestContext < TestCase
class TestInputMethod < ::IRB::InputMethod
attr_reader :list, :line_no

def initialize(list = [])
super("test")
@line_no = 0
@list = list
end

def gets
@list[@line_no]&.tap {@line_no += 1}
end

def eof?
@line_no >= @list.size
end

def encoding
Encoding.default_external
end

def reset
@line_no = 0
end
end

def setup
IRB.init_config(nil)
IRB.conf[:USE_SINGLELINE] = false
Expand Down
34 changes: 3 additions & 31 deletions test/irb/test_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,10 @@ def teardown
IRB.conf[:RC_NAME_GENERATOR] = nil
end

class TestInputMethod < ::IRB::InputMethod
class TestInputMethodWithHistory < TestInputMethod
HISTORY = Array.new

include IRB::HistorySavingAbility

attr_reader :list, :line_no

def initialize(list = [])
super("test")
@line_no = 0
@list = list
end

def gets
@list[@line_no]&.tap {@line_no += 1}
end

def eof?
@line_no >= @list.size
end

def encoding
Encoding.default_external
end

def reset
@line_no = 0
end

def winsize
[10, 20]
end
end

def test_history_save_1
Expand Down Expand Up @@ -167,7 +139,7 @@ def test_history_concurrent_use_not_present
IRB.conf[:SAVE_HISTORY] = 1
Dir.mktmpdir("test_irb_history_") do |tmpdir|
ENV["HOME"] = tmpdir
io = TestInputMethod.new
io = TestInputMethodWithHistory.new
io.class::HISTORY.clear
io.load_history
io.class::HISTORY.concat(%w"line1 line2")
Expand Down Expand Up @@ -198,7 +170,7 @@ def assert_history(expected_history, initial_irb_history, input)
f.write(initial_irb_history)
end

io = TestInputMethod.new
io = TestInputMethodWithHistory.new
io.class::HISTORY.clear
io.load_history
if block_given?
Expand Down