Skip to content

Commit 4b831d0

Browse files
st0012hsbt
authored andcommitted
Remove duplicated TestInputMethod definitions
1 parent 5942949 commit 4b831d0

File tree

4 files changed

+29
-83
lines changed

4 files changed

+29
-83
lines changed

test/irb/helper.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
module TestIRB
44
class TestCase < Test::Unit::TestCase
5+
class TestInputMethod < ::IRB::InputMethod
6+
attr_reader :list, :line_no
7+
8+
def initialize(list = [])
9+
super("test")
10+
@line_no = 0
11+
@list = list
12+
end
13+
14+
def gets
15+
@list[@line_no]&.tap {@line_no += 1}
16+
end
17+
18+
def eof?
19+
@line_no >= @list.size
20+
end
21+
22+
def encoding
23+
Encoding.default_external
24+
end
25+
26+
def reset
27+
@line_no = 0
28+
end
29+
end
30+
531
def save_encodings
632
@default_encoding = [Encoding.default_external, Encoding.default_internal]
733
@stdio_encodings = [STDIN, STDOUT, STDERR].map {|io| [io.external_encoding, io.internal_encoding] }

test/irb/test_cmd.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66

77
module TestIRB
88
class ExtendCommandTest < TestCase
9-
class TestInputMethod < ::IRB::InputMethod
10-
attr_reader :list, :line_no
11-
12-
def initialize(list = [])
13-
super("test")
14-
@line_no = 0
15-
@list = list
16-
end
17-
18-
def gets
19-
@list[@line_no]&.tap {@line_no += 1}
20-
end
21-
22-
def eof?
23-
@line_no >= @list.size
24-
end
25-
26-
def encoding
27-
Encoding.default_external
28-
end
29-
30-
def reset
31-
@line_no = 0
32-
end
33-
end
34-
359
def setup
3610
@pwd = Dir.pwd
3711
@tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}")

test/irb/test_context.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,6 @@
77

88
module TestIRB
99
class TestContext < TestCase
10-
class TestInputMethod < ::IRB::InputMethod
11-
attr_reader :list, :line_no
12-
13-
def initialize(list = [])
14-
super("test")
15-
@line_no = 0
16-
@list = list
17-
end
18-
19-
def gets
20-
@list[@line_no]&.tap {@line_no += 1}
21-
end
22-
23-
def eof?
24-
@line_no >= @list.size
25-
end
26-
27-
def encoding
28-
Encoding.default_external
29-
end
30-
31-
def reset
32-
@line_no = 0
33-
end
34-
end
35-
3610
def setup
3711
IRB.init_config(nil)
3812
IRB.conf[:USE_SINGLELINE] = false

test/irb/test_history.rb

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,10 @@ def teardown
1515
IRB.conf[:RC_NAME_GENERATOR] = nil
1616
end
1717

18-
class TestInputMethod < ::IRB::InputMethod
18+
class TestInputMethodWithHistory < TestInputMethod
1919
HISTORY = Array.new
2020

2121
include IRB::HistorySavingAbility
22-
23-
attr_reader :list, :line_no
24-
25-
def initialize(list = [])
26-
super("test")
27-
@line_no = 0
28-
@list = list
29-
end
30-
31-
def gets
32-
@list[@line_no]&.tap {@line_no += 1}
33-
end
34-
35-
def eof?
36-
@line_no >= @list.size
37-
end
38-
39-
def encoding
40-
Encoding.default_external
41-
end
42-
43-
def reset
44-
@line_no = 0
45-
end
46-
47-
def winsize
48-
[10, 20]
49-
end
5022
end
5123

5224
def test_history_save_1
@@ -167,7 +139,7 @@ def test_history_concurrent_use_not_present
167139
IRB.conf[:SAVE_HISTORY] = 1
168140
Dir.mktmpdir("test_irb_history_") do |tmpdir|
169141
ENV["HOME"] = tmpdir
170-
io = TestInputMethod.new
142+
io = TestInputMethodWithHistory.new
171143
io.class::HISTORY.clear
172144
io.load_history
173145
io.class::HISTORY.concat(%w"line1 line2")
@@ -198,7 +170,7 @@ def assert_history(expected_history, initial_irb_history, input)
198170
f.write(initial_irb_history)
199171
end
200172

201-
io = TestInputMethod.new
173+
io = TestInputMethodWithHistory.new
202174
io.class::HISTORY.clear
203175
io.load_history
204176
if block_given?

0 commit comments

Comments
 (0)