summaryrefslogtreecommitdiff
path: root/test/date
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-06-15 10:39:42 -0700
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-07-11 20:28:21 +0900
commit8065670cfbfcf89249c2de12a513b5c7308c9aeb (patch)
treea8e9044dd8879f9ec2bf91c349fac25a9a5a0e97 /test/date
parent49ba7cd2598e047aba37c204c143ce6ee2364e8c (diff)
downloadruby-8065670cfbfcf89249c2de12a513b5c7308c9aeb.tar.gz
[ruby/date] Fix comparison with Float::INFINITY
Fixes [Bug #17945] https://github.com/ruby/date/commit/953d907238
Diffstat (limited to 'test/date')
-rw-r--r--test/date/test_date.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/date/test_date.rb b/test/date/test_date.rb
index ebd75ae12d..6e99bc562c 100644
--- a/test/date/test_date.rb
+++ b/test/date/test_date.rb
@@ -163,4 +163,16 @@ class TestDate < Test::Unit::TestCase
assert_equal(1, d2 <=> d1)
end
+ def test_infinity_comparison
+ assert_equal(0, Float::INFINITY <=> Date::Infinity.new)
+ assert_equal(0, Date::Infinity.new <=> Float::INFINITY)
+ assert_equal(0, -Float::INFINITY <=> -Date::Infinity.new)
+ assert_equal(0, -Date::Infinity.new <=> -Float::INFINITY)
+
+ assert_equal(1, Float::INFINITY <=> -Date::Infinity.new)
+ assert_equal(1, Date::Infinity.new <=> -Float::INFINITY)
+
+ assert_equal(-1, -Float::INFINITY <=> Date::Infinity.new)
+ assert_equal(-1, -Date::Infinity.new <=> Float::INFINITY)
+ end
end