[ruby/reline] Add a test for key bindings with Reline::Key
https://github.com/ruby/reline/commit/cadbd576c7
This commit is contained in:
parent
83a0807b3b
commit
540eea39dd
@ -58,4 +58,22 @@ class Reline::KeyStroke::Test < Reline::TestCase
|
||||
assert_equal(:unmatched, stroke.match_status('zzz'.bytes))
|
||||
assert_equal(:matched, stroke.match_status('abc'.bytes))
|
||||
end
|
||||
|
||||
def test_with_reline_key
|
||||
config = Reline::Config.new
|
||||
{
|
||||
[
|
||||
Reline::Key.new(100, 228, true), # Alt+d
|
||||
Reline::Key.new(97, 97, false) # a
|
||||
] => 'abc',
|
||||
[195, 164] => 'def'
|
||||
}.each_pair do |key, func|
|
||||
config.add_oneshot_key_binding(key, func.bytes)
|
||||
end
|
||||
stroke = Reline::KeyStroke.new(config)
|
||||
assert_equal(:unmatched, stroke.match_status('da'.bytes))
|
||||
assert_equal(:matched, stroke.match_status("\M-da".bytes))
|
||||
assert_equal(:unmatched, stroke.match_status([32, 195, 164]))
|
||||
assert_equal(:matched, stroke.match_status([195, 164]))
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user