summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index ee51c8ed7d..4f48d3b90c 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1308,6 +1308,31 @@ class TestHash < Test::Unit::TestCase
assert_nil(h.dig(:c, 1))
end
+ def test_cmp
+ h1 = {a:1, b:2}
+ h2 = {a:1, b:2, c:3}
+
+ assert_operator(h1, :<=, h1)
+ assert_operator(h1, :<=, h2)
+ assert_not_operator(h2, :<=, h1)
+ assert_operator(h2, :<=, h2)
+
+ assert_operator(h1, :>=, h1)
+ assert_not_operator(h1, :>=, h2)
+ assert_operator(h2, :>=, h1)
+ assert_operator(h2, :>=, h2)
+
+ assert_not_operator(h1, :<, h1)
+ assert_operator(h1, :<, h2)
+ assert_not_operator(h2, :<, h1)
+ assert_not_operator(h2, :<, h2)
+
+ assert_not_operator(h1, :>, h1)
+ assert_not_operator(h1, :>, h2)
+ assert_operator(h2, :>, h1)
+ assert_not_operator(h2, :>, h2)
+ end
+
class TestSubHash < TestHash
class SubHash < Hash
def reject(*)