From 83a0807b3be32fea7ddb5f66bd40193e5981f6b9 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 6 Sep 2021 07:01:46 +0900 Subject: [PATCH] [ruby/reline] Add a test for oneshot key bindings https://github.com/ruby/reline/commit/42ebea82b7 --- test/reline/test_key_stroke.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/reline/test_key_stroke.rb b/test/reline/test_key_stroke.rb index 642ff5478d..7971598162 100644 --- a/test/reline/test_key_stroke.rb +++ b/test/reline/test_key_stroke.rb @@ -46,4 +46,16 @@ class Reline::KeyStroke::Test < Reline::TestCase stroke = Reline::KeyStroke.new(config) assert_equal('123'.bytes, stroke.expand('abc'.bytes)) end + + def test_oneshot_key_bindings + config = Reline::Config.new + { + 'abc' => '123', + }.each_pair do |key, func| + config.add_default_key_binding(key.bytes, func.bytes) + end + stroke = Reline::KeyStroke.new(config) + assert_equal(:unmatched, stroke.match_status('zzz'.bytes)) + assert_equal(:matched, stroke.match_status('abc'.bytes)) + end end