[前][次][番号順一覧][スレッド一覧]

ruby-changes:58389

From: Jeremy <ko1@a...>
Date: Thu, 24 Oct 2019 18:39:35 +0900 (JST)
Subject: [ruby-changes:58389] fc0e8d00bc (master): [ruby/date] Support -Float::INFINITY...date ranges

https://git.ruby-lang.org/ruby.git/commit/?id=fc0e8d00bc

From fc0e8d00bc50ac8646b37adee3b599c83ce84a41 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Sun, 25 Aug 2019 10:01:13 -0700
Subject: [ruby/date] Support -Float::INFINITY...date ranges

Fixes Ruby Bug 12961

https://github.com/ruby/date/commit/7f533c2552

diff --git a/ext/date/lib/date.rb b/ext/date/lib/date.rb
index 9170a99..b72b415 100644
--- a/ext/date/lib/date.rb
+++ b/ext/date/lib/date.rb
@@ -5,6 +5,10 @@ require 'date_core' https://github.com/ruby/ruby/blob/trunk/ext/date/lib/date.rb#L5
 
 class Date
 
+  def infinite?
+    false
+  end
+
   class Infinity < Numeric # :nodoc:
 
     include Comparable
diff --git a/test/date/test_date.rb b/test/date/test_date.rb
index 03e935e..ebd75ae 100644
--- a/test/date/test_date.rb
+++ b/test/date/test_date.rb
@@ -6,6 +6,19 @@ class DateSub < Date; end https://github.com/ruby/ruby/blob/trunk/test/date/test_date.rb#L6
 class DateTimeSub < DateTime; end
 
 class TestDate < Test::Unit::TestCase
+  def test_range_infinite_float
+    today = Date.today
+    r = today...Float::INFINITY
+    assert_equal today, r.begin
+    assert_equal Float::INFINITY, r.end
+    assert_equal true, r.cover?(today+1)
+    assert_equal false, r.cover?(today-1)
+    r = (-Float::INFINITY)...today
+    assert_equal(-Float::INFINITY, r.begin)
+    assert_equal today, r.end
+    assert_equal false, r.cover?(today+1)
+    assert_equal true, r.cover?(today-1)
+  end
 
   def test__const
     assert_nil(Date::MONTHNAMES[0])
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]