1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add a test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-12-22 14:02:13 +00:00
parent 3da3230f0c
commit 8d7677b498

View file

@ -351,6 +351,22 @@ class TestTime < Test::Unit::TestCase
assert_equal(T2000 + 1, T2000.succ) assert_equal(T2000 + 1, T2000.succ)
end end
def test_plus_type
t0 = Time.utc(2000,1,1)
n0 = t0.to_i
n1 = n0+1
t1 = Time.at(n1)
assert_equal(t1, t0 + 1)
assert_equal(t1, t0 + 1.0)
assert_equal(t1, t0 + Rational(1,1))
assert_equal(t1, t0 + SimpleDelegator.new(1))
assert_equal(t1, t0 + SimpleDelegator.new(1.0))
assert_equal(t1, t0 + SimpleDelegator.new(Rational(1,1)))
assert_raise(TypeError) { t0 + nil }
assert_raise(TypeError) { t0 + "1" }
assert_raise(TypeError) { t0 + SimpleDelegator.new("1") }
end
def test_readers def test_readers
assert_equal(0, T2000.sec) assert_equal(0, T2000.sec)
assert_equal(0, T2000.min) assert_equal(0, T2000.min)