[ruby/reline] Add a test for key bindings with Reline::Key

https://github.com/ruby/reline/commit/cadbd576c7
This commit is contained in:
aycabta 2021-09-06 07:03:48 +09:00 committed by git
parent 83a0807b3b
commit 540eea39dd

View File

@ -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