@@ -126,41 +126,46 @@ def test_invalid_keystroke
126
126
end
127
127
128
128
def test_bind_key
129
- assert_equal [ 'input' . bytes , 'abcde' . bytes ] , @config . bind_key ( '"input"' , '"abcde"' )
129
+ assert_equal [ 'input' . bytes , 'abcde' . bytes ] , @config . parse_key_binding ( '"input"' , '"abcde"' )
130
130
end
131
131
132
132
def test_bind_key_with_macro
133
133
134
- assert_equal [ 'input' . bytes , :abcde ] , @config . bind_key ( '"input"' , 'abcde' )
134
+ assert_equal [ 'input' . bytes , :abcde ] , @config . parse_key_binding ( '"input"' , 'abcde' )
135
135
end
136
136
137
137
def test_bind_key_with_escaped_chars
138
- assert_equal [ 'input' . bytes , "\e \\ \" ' \a \b \d \f \n \r \t \v " . bytes ] , @config . bind_key ( '"input"' , '"\\e \\\\ \\" \\\' \\a \\b \\d \\f \\n \\r \\t \\v"' )
138
+ assert_equal [ 'input' . bytes , "\e \\ \" ' \a \b \d \f \n \r \t \v " . bytes ] , @config . parse_key_binding ( '"input"' , '"\\e \\\\ \\" \\\' \\a \\b \\d \\f \\n \\r \\t \\v"' )
139
139
end
140
140
141
141
def test_bind_key_with_ctrl_chars
142
- assert_equal [ 'input' . bytes , "\C -h\C -h" . bytes ] , @config . bind_key ( '"input"' , '"\C-h\C-H"' )
143
- assert_equal [ 'input' . bytes , "\C -h\C -h" . bytes ] , @config . bind_key ( '"input"' , '"\Control-h\Control-H"' )
142
+ assert_equal [ 'input' . bytes , "\C -h\C -h\C -_ " . bytes ] , @config . parse_key_binding ( '"input"' , '"\C-h\C-H\C-_ "' )
143
+ assert_equal [ 'input' . bytes , "\C -h\C -h\C -_ " . bytes ] , @config . parse_key_binding ( '"input"' , '"\Control-h\Control-H\Control-_ "' )
144
144
end
145
145
146
146
def test_bind_key_with_meta_chars
147
- assert_equal [ 'input' . bytes , "\M -h\M -H" . bytes ] , @config . bind_key ( '"input"' , '"\M-h\M-H"' )
148
- assert_equal [ 'input' . bytes , "\M -h\M -H" . bytes ] , @config . bind_key ( '"input"' , '"\Meta-h\Meta-H"' )
147
+ assert_equal [ 'input' . bytes , "\e h\e H\e _" . bytes ] , @config . parse_key_binding ( '"input"' , '"\M-h\M-H\M-_"' )
148
+ assert_equal [ 'input' . bytes , "\e h\e H\e _" . bytes ] , @config . parse_key_binding ( '"input"' , '"\Meta-h\Meta-H\M-_"' )
149
+ end
150
+
151
+ def test_bind_key_with_ctrl_meta_chars
152
+ assert_equal [ 'input' . bytes , "\e \C -h\e \C -h\e \C -_" . bytes ] , @config . parse_key_binding ( '"input"' , '"\M-\C-h\C-\M-H\M-\C-_"' )
153
+ assert_equal [ 'input' . bytes , "\e \C -h\e \C -_" . bytes ] , @config . parse_key_binding ( '"input"' , '"\Meta-\Control-h\Control-\Meta-_"' )
149
154
end
150
155
151
156
def test_bind_key_with_octal_number
152
157
input = %w{ i n p u t } . map ( &:ord )
153
- assert_equal [ input , "\1 " . bytes ] , @config . bind_key ( '"input"' , '"\1"' )
154
- assert_equal [ input , "\12 " . bytes ] , @config . bind_key ( '"input"' , '"\12"' )
155
- assert_equal [ input , "\123 " . bytes ] , @config . bind_key ( '"input"' , '"\123"' )
156
- assert_equal [ input , "\123 " . bytes + '4' . bytes ] , @config . bind_key ( '"input"' , '"\1234"' )
158
+ assert_equal [ input , "\1 " . bytes ] , @config . parse_key_binding ( '"input"' , '"\1"' )
159
+ assert_equal [ input , "\12 " . bytes ] , @config . parse_key_binding ( '"input"' , '"\12"' )
160
+ assert_equal [ input , "\123 " . bytes ] , @config . parse_key_binding ( '"input"' , '"\123"' )
161
+ assert_equal [ input , "\123 " . bytes + '4' . bytes ] , @config . parse_key_binding ( '"input"' , '"\1234"' )
157
162
end
158
163
159
164
def test_bind_key_with_hexadecimal_number
160
165
input = %w{ i n p u t } . map ( &:ord )
161
- assert_equal [ input , "\x4 " . bytes ] , @config . bind_key ( '"input"' , '"\x4"' )
162
- assert_equal [ input , "\x45 " . bytes ] , @config . bind_key ( '"input"' , '"\x45"' )
163
- assert_equal [ input , "\x45 " . bytes + '6' . bytes ] , @config . bind_key ( '"input"' , '"\x456"' )
166
+ assert_equal [ input , "\x4 " . bytes ] , @config . parse_key_binding ( '"input"' , '"\x4"' )
167
+ assert_equal [ input , "\x45 " . bytes ] , @config . parse_key_binding ( '"input"' , '"\x45"' )
168
+ assert_equal [ input , "\x45 " . bytes + '6' . bytes ] , @config . parse_key_binding ( '"input"' , '"\x456"' )
164
169
end
165
170
166
171
def test_include
@@ -384,6 +389,20 @@ def test_additional_key_bindings
384
389
assert_equal expected , registered_key_bindings ( expected . keys )
385
390
end
386
391
392
+ def test_unquoted_additional_key_bindings
393
+ @config . read_lines ( <<~'LINES' . lines )
394
+ Meta-a: "Ma"
395
+ Control-b: "Cb"
396
+ Meta-Control-c: "MCc"
397
+ Control-Meta-d: "CMd"
398
+ M-C-e: "MCe"
399
+ C-M-f: "CMf"
400
+ LINES
401
+
402
+ expected = { "\e a" . bytes => 'Ma' . bytes , "\C -b" . bytes => 'Cb' . bytes , "\e \C -c" . bytes => 'MCc' . bytes , "\e \C -d" . bytes => 'CMd' . bytes , "\e \C -e" . bytes => 'MCe' . bytes , "\e \C -f" . bytes => 'CMf' . bytes }
403
+ assert_equal expected , registered_key_bindings ( expected . keys )
404
+ end
405
+
387
406
def test_additional_key_bindings_with_nesting_and_comment_out
388
407
@config . read_lines ( <<~'LINES' . lines )
389
408
#"ab": "AB"
0 commit comments