mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
[ruby/reline] Rename matches? as match?
(https://github.com/ruby/reline/pull/753) https://github.com/ruby/reline/commit/9230fe162d
This commit is contained in:
parent
5bf8a53063
commit
9d4af312bd
@ -252,7 +252,7 @@ class Reline::Windows < Reline::IO
|
||||
|
||||
key = KeyEventRecord.new(virtual_key_code, char_code, control_key_state)
|
||||
|
||||
match = KEY_MAP.find { |args,| key.matches?(**args) }
|
||||
match = KEY_MAP.find { |args,| key.match?(**args) }
|
||||
unless match.nil?
|
||||
@output_buf.concat(match.last)
|
||||
return
|
||||
@ -501,7 +501,7 @@ class Reline::Windows < Reline::IO
|
||||
# Verifies if the arguments match with this key event.
|
||||
# Nil arguments are ignored, but at least one must be passed as non-nil.
|
||||
# To verify that no control keys were pressed, pass an empty array: `control_keys: []`.
|
||||
def matches?(control_keys: nil, virtual_key_code: nil, char_code: nil)
|
||||
def match?(control_keys: nil, virtual_key_code: nil, char_code: nil)
|
||||
raise ArgumentError, 'No argument was passed to match key event' if control_keys.nil? && virtual_key_code.nil? && char_code.nil?
|
||||
|
||||
(control_keys.nil? || [*control_keys].sort == @control_keys) &&
|
||||
|
||||
@ -10,31 +10,31 @@ class Reline::Windows
|
||||
end
|
||||
|
||||
def test_matches__with_no_arguments_raises_error
|
||||
assert_raise(ArgumentError) { @key.matches? }
|
||||
assert_raise(ArgumentError) { @key.match? }
|
||||
end
|
||||
|
||||
def test_matches_char_code
|
||||
assert @key.matches?(char_code: 0x1)
|
||||
assert @key.match?(char_code: 0x1)
|
||||
end
|
||||
|
||||
def test_matches_virtual_key_code
|
||||
assert @key.matches?(virtual_key_code: 0x41)
|
||||
assert @key.match?(virtual_key_code: 0x41)
|
||||
end
|
||||
|
||||
def test_matches_control_keys
|
||||
assert @key.matches?(control_keys: :CTRL)
|
||||
assert @key.match?(control_keys: :CTRL)
|
||||
end
|
||||
|
||||
def test_doesnt_match_alt
|
||||
refute @key.matches?(control_keys: :ALT)
|
||||
refute @key.match?(control_keys: :ALT)
|
||||
end
|
||||
|
||||
def test_doesnt_match_empty_control_key
|
||||
refute @key.matches?(control_keys: [])
|
||||
refute @key.match?(control_keys: [])
|
||||
end
|
||||
|
||||
def test_matches_control_keys_and_virtual_key_code
|
||||
assert @key.matches?(control_keys: :CTRL, virtual_key_code: 0x41)
|
||||
assert @key.match?(control_keys: :CTRL, virtual_key_code: 0x41)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user