@@ -24,8 +24,12 @@ def teardown
24
24
ENV [ 'INPUTRC' ] = @inputrc_backup
25
25
end
26
26
27
+ def get_config_variable ( variable )
28
+ @config . instance_variable_get ( variable )
29
+ end
30
+
27
31
def additional_key_bindings ( keymap_label )
28
- @config . instance_variable_get ( :@additional_key_bindings ) [ keymap_label ] . instance_variable_get ( :@key_bindings )
32
+ get_config_variable ( :@additional_key_bindings ) [ keymap_label ] . instance_variable_get ( :@key_bindings )
29
33
end
30
34
31
35
def registered_key_bindings ( keys )
@@ -38,15 +42,15 @@ def test_read_lines
38
42
set show-mode-in-prompt on
39
43
LINES
40
44
41
- assert_equal true , @config . instance_variable_get ( :@show_mode_in_prompt )
45
+ assert_equal true , get_config_variable ( :@show_mode_in_prompt )
42
46
end
43
47
44
48
def test_read_lines_with_variable
45
49
@config . read_lines ( <<~LINES . lines )
46
50
set disable-completion on
47
51
LINES
48
52
49
- assert_equal true , @config . instance_variable_get ( :@disable_completion )
53
+ assert_equal true , get_config_variable ( :@disable_completion )
50
54
end
51
55
52
56
def test_string_value
@@ -55,7 +59,7 @@ def test_string_value
55
59
set emacs-mode-string Emacs
56
60
LINES
57
61
58
- assert_equal 'Emacs' , @config . instance_variable_get ( :@emacs_mode_string )
62
+ assert_equal 'Emacs' , get_config_variable ( :@emacs_mode_string )
59
63
end
60
64
61
65
def test_string_value_with_brackets
@@ -64,7 +68,7 @@ def test_string_value_with_brackets
64
68
set emacs-mode-string [Emacs]
65
69
LINES
66
70
67
- assert_equal '[Emacs]' , @config . instance_variable_get ( :@emacs_mode_string )
71
+ assert_equal '[Emacs]' , get_config_variable ( :@emacs_mode_string )
68
72
end
69
73
70
74
def test_string_value_with_brackets_and_quotes
@@ -73,7 +77,7 @@ def test_string_value_with_brackets_and_quotes
73
77
set emacs-mode-string "[Emacs]"
74
78
LINES
75
79
76
- assert_equal '[Emacs]' , @config . instance_variable_get ( :@emacs_mode_string )
80
+ assert_equal '[Emacs]' , get_config_variable ( :@emacs_mode_string )
77
81
end
78
82
79
83
def test_string_value_with_parens
@@ -82,7 +86,7 @@ def test_string_value_with_parens
82
86
set emacs-mode-string (Emacs)
83
87
LINES
84
88
85
- assert_equal '(Emacs)' , @config . instance_variable_get ( :@emacs_mode_string )
89
+ assert_equal '(Emacs)' , get_config_variable ( :@emacs_mode_string )
86
90
end
87
91
88
92
def test_string_value_with_parens_and_quotes
@@ -91,7 +95,7 @@ def test_string_value_with_parens_and_quotes
91
95
set emacs-mode-string "(Emacs)"
92
96
LINES
93
97
94
- assert_equal '(Emacs)' , @config . instance_variable_get ( :@emacs_mode_string )
98
+ assert_equal '(Emacs)' , get_config_variable ( :@emacs_mode_string )
95
99
end
96
100
97
101
def test_encoding_is_ascii
@@ -105,7 +109,7 @@ def test_encoding_is_ascii
105
109
def test_encoding_is_not_ascii
106
110
@config = Reline ::Config . new
107
111
108
- assert_equal nil , @config . convert_meta
112
+ assert_equal false , @config . convert_meta
109
113
end
110
114
111
115
def test_invalid_keystroke
@@ -169,7 +173,7 @@ def test_include
169
173
$include included_partial
170
174
LINES
171
175
172
- assert_equal true , @config . instance_variable_get ( :@show_mode_in_prompt )
176
+ assert_equal true , get_config_variable ( :@show_mode_in_prompt )
173
177
end
174
178
175
179
def test_include_expand_path
@@ -184,7 +188,7 @@ def test_include_expand_path
184
188
$include ~/included_partial
185
189
LINES
186
190
187
- assert_equal true , @config . instance_variable_get ( :@show_mode_in_prompt )
191
+ assert_equal true , get_config_variable ( :@show_mode_in_prompt )
188
192
ensure
189
193
ENV [ 'HOME' ] = home_backup
190
194
end
@@ -198,7 +202,7 @@ def test_if
198
202
$endif
199
203
LINES
200
204
201
- assert_equal '(cmd)' , @config . instance_variable_get ( :@vi_cmd_mode_string )
205
+ assert_equal '(cmd)' , get_config_variable ( :@vi_cmd_mode_string )
202
206
end
203
207
204
208
def test_if_with_false
@@ -210,7 +214,7 @@ def test_if_with_false
210
214
$endif
211
215
LINES
212
216
213
- assert_equal '[cmd]' , @config . instance_variable_get ( :@vi_cmd_mode_string )
217
+ assert_equal '[cmd]' , get_config_variable ( :@vi_cmd_mode_string )
214
218
end
215
219
216
220
def test_if_with_indent
@@ -224,7 +228,7 @@ def test_if_with_indent
224
228
$endif
225
229
LINES
226
230
227
- assert_equal '(cmd)' , @config . instance_variable_get ( :@vi_cmd_mode_string )
231
+ assert_equal '(cmd)' , get_config_variable ( :@vi_cmd_mode_string )
228
232
end
229
233
end
230
234
@@ -446,7 +450,7 @@ def test_history_size
446
450
set history-size 5000
447
451
LINES
448
452
449
- assert_equal 5000 , @config . instance_variable_get ( :@history_size )
453
+ assert_equal 5000 , get_config_variable ( :@history_size )
450
454
history = Reline ::History . new ( @config )
451
455
history << "a\n "
452
456
assert_equal 1 , history . size
@@ -477,7 +481,7 @@ def test_inputrc_raw_value
477
481
set vi-ins-mode-string aaa aaa
478
482
set vi-cmd-mode-string bbb ccc # comment
479
483
LINES
480
- assert_equal :vi_insert , @config . instance_variable_get ( :@editing_mode_label )
484
+ assert_equal :vi_insert , get_config_variable ( :@editing_mode_label )
481
485
assert_equal 'aaa aaa' , @config . vi_ins_mode_string
482
486
assert_equal 'bbb ccc # comment' , @config . vi_cmd_mode_string
483
487
end
@@ -576,5 +580,9 @@ def test_reload
576
580
File . write ( inputrc , "set emacs-mode-string ?" )
577
581
@config . reload
578
582
assert_equal '?' , @config . emacs_mode_string
583
+
584
+ File . write ( inputrc , "" )
585
+ @config . reload
586
+ assert_equal '@' , @config . emacs_mode_string
579
587
end
580
588
end
0 commit comments