зеркало из https://github.com/github/ruby.git
[ruby/date] Support -Float::INFINITY...date ranges
Fixes Ruby Bug 12961 https://github.com/ruby/date/commit/7f533c2552
This commit is contained in:
Родитель
4e40ca301c
Коммит
fc0e8d00bc
|
@ -5,6 +5,10 @@ require 'date_core'
|
|||
|
||||
class Date
|
||||
|
||||
def infinite?
|
||||
false
|
||||
end
|
||||
|
||||
class Infinity < Numeric # :nodoc:
|
||||
|
||||
include Comparable
|
||||
|
|
|
@ -6,6 +6,19 @@ class DateSub < Date; end
|
|||
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])
|
||||
|
|
Загрузка…
Ссылка в новой задаче