summaryrefslogtreecommitdiff
path: root/test/date
diff options
context:
space:
mode:
Diffstat (limited to 'test/date')
-rw-r--r--test/date/test_date_arith.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/date/test_date_arith.rb b/test/date/test_date_arith.rb
index 94822e5764..e1f29dbf22 100644
--- a/test/date/test_date_arith.rb
+++ b/test/date/test_date_arith.rb
@@ -3,11 +3,18 @@ require 'test/unit'
require 'date'
class TestDateArith < Test::Unit::TestCase
+ class Rat < Numeric
+ def to_r; self; end
+ end
def test_new_offset
d = DateTime.new(2002, 3, 14)
assert_equal(Rational(9, 24), d.new_offset(Rational(9, 24)).offset)
assert_equal(Rational(9, 24), d.new_offset('+0900').offset)
+ n = Rat.new
+ assert_raise(TypeError) do
+ Timeout.timeout(1) {d.new_offset(n)}
+ end
end
def test__plus
@@ -37,6 +44,13 @@ class TestDateArith < Test::Unit::TestCase
assert_raise(e) do
DateTime.new(2000,2,29) + Time.mktime(2000,2,29)
end
+ n = Rat.new
+ assert_raise(e) do
+ Timeout.timeout(1) {Date.new(2000,2,29) + n}
+ end
+ assert_raise(e) do
+ Timeout.timeout(1) {DateTime.new(2000,2,29) + n}
+ end
end
def test__minus