File tree Expand file tree Collapse file tree 3 files changed +20
-13
lines changed Expand file tree Collapse file tree 3 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 3
3
class Reline ::GeneralIO
4
4
def self . reset ( encoding : nil )
5
5
@@pasting = false
6
- @@encoding = encoding
6
+ if encoding
7
+ @@encoding = encoding
8
+ elsif defined? ( @@encoding )
9
+ remove_class_variable ( :@@encoding )
10
+ end
7
11
end
8
12
9
13
def self . encoding
Original file line number Diff line number Diff line change 21
21
module Reline
22
22
class <<self
23
23
def test_mode ( ansi : false )
24
- remove_const ( 'IOGate' ) if const_defined? ( 'IOGate' )
25
- const_set ( 'IOGate' , ansi ? Reline ::ANSI : Reline ::GeneralIO )
26
- if ENV [ 'RELINE_TEST_ENCODING' ]
27
- encoding = Encoding . find ( ENV [ 'RELINE_TEST_ENCODING' ] )
28
- else
29
- encoding = Encoding ::UTF_8
30
- end
31
- Reline ::GeneralIO . reset ( encoding : encoding ) unless ansi
32
- core . config . instance_variable_set ( :@test_mode , true )
33
- core . config . reset
24
+ @original_iogate = IOGate
25
+ remove_const ( 'IOGate' )
26
+ const_set ( 'IOGate' , ansi ? Reline ::ANSI : Reline ::GeneralIO )
27
+ if ENV [ 'RELINE_TEST_ENCODING' ]
28
+ encoding = Encoding . find ( ENV [ 'RELINE_TEST_ENCODING' ] )
29
+ else
30
+ encoding = Encoding ::UTF_8
31
+ end
32
+ Reline ::GeneralIO . reset ( encoding : encoding ) unless ansi
33
+ core . config . instance_variable_set ( :@test_mode , true )
34
+ core . config . reset
34
35
end
35
36
36
37
def test_reset
37
- remove_const ( 'IOGate' ) if const_defined? ( 'IOGate' )
38
- const_set ( 'IOGate' , Reline ::GeneralIO )
38
+ remove_const ( 'IOGate' )
39
+ const_set ( 'IOGate' , @original_iogate )
40
+ Reline ::GeneralIO . reset
39
41
Reline . instance_variable_set ( :@core , nil )
40
42
end
41
43
Original file line number Diff line number Diff line change 3
3
4
4
class Reline ::TestKey < Reline ::TestCase
5
5
def setup
6
+ Reline . test_mode
6
7
end
7
8
8
9
def teardown
You can’t perform that action at this time.
0 commit comments