1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/reline/test_reline_key.rb

54 lines
1.9 KiB
Ruby
Raw Normal View History

require_relative 'helper'
require "reline"
class Reline::TestKey < Reline::TestCase
def setup
end
def teardown
Reline.test_reset
end
def test_match_key
assert(Reline::Key.new(1, 2, false).match?(Reline::Key.new(1, 2, false)))
assert(Reline::Key.new(1, 2, false).match?(Reline::Key.new(nil, 2, false)))
assert(Reline::Key.new(1, 2, false).match?(Reline::Key.new(1, 2, nil)))
assert(Reline::Key.new(nil, 2, false).match?(Reline::Key.new(nil, 2, false)))
assert(Reline::Key.new(1, nil, false).match?(Reline::Key.new(1, nil, false)))
assert(Reline::Key.new(1, 2, nil).match?(Reline::Key.new(1, 2, nil)))
assert(Reline::Key.new(nil, 2, false).match?(Reline::Key.new(nil, 2, false)))
assert(Reline::Key.new(1, nil, false).match?(Reline::Key.new(1, nil, false)))
assert(Reline::Key.new(1, 2, nil).match?(Reline::Key.new(1, 2, nil)))
assert(!Reline::Key.new(1, 2, false).match?(Reline::Key.new(3, 1, false)))
assert(!Reline::Key.new(1, 2, false).match?(Reline::Key.new(1, 3, false)))
assert(!Reline::Key.new(1, 2, false).match?(Reline::Key.new(1, 3, true)))
end
def test_match_integer
assert(Reline::Key.new(1, 2, false).match?(2))
assert(Reline::Key.new(nil, 2, false).match?(2))
assert(Reline::Key.new(1, nil, false).match?(1))
assert(!Reline::Key.new(1, 2, false).match?(1))
assert(!Reline::Key.new(1, nil, false).match?(2))
assert(!Reline::Key.new(nil, nil, false).match?(1))
end
def test_match_symbol
assert(Reline::Key.new(:key1, :key2, false).match?(:key2))
assert(Reline::Key.new(:key1, nil, false).match?(:key1))
assert(!Reline::Key.new(:key1, :key2, false).match?(:key1))
assert(!Reline::Key.new(:key1, nil, false).match?(:key2))
assert(!Reline::Key.new(nil, nil, false).match?(:key1))
end
def test_match_other
assert(!Reline::Key.new(:key1, 2, false).match?("key1"))
assert(!Reline::Key.new(nil, nil, false).match?(nil))
end
end