summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-12 18:00:25 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-12 18:00:25 +0000
commit87d95fdbc892847d52145a56037c6dae0d4691ff (patch)
tree61392ef423386be6845a31f7419142f1cd5de0b4 /test
parentf64e076260cf60b25d78dcfe157c3b4e8c704ce5 (diff)
add test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_time.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 2bc03a631a..8718dbc327 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -14,6 +14,13 @@ class TestTime < Test::Unit::TestCase
$VERBOSE = @verbose
end
+ def test_new
+ assert_equal(Time.utc(2000,2,10), Time.new(2000,2,10, 11,0,0, 3600*11))
+ assert_equal(Time.utc(2000,2,10), Time.new(2000,2,9, 13,0,0, -3600*11))
+ assert_equal(Time.utc(2000,2,10), Time.new(2000,2,10, 11,0,0, "+11:00"))
+ assert_equal(Rational(1,2), Time.new(2000,2,10, 11,0,5.5, "+11:00").subsec)
+ end
+
def test_time_add()
assert_equal(Time.utc(2000, 3, 21, 3, 30) + 3 * 3600,
Time.utc(2000, 3, 21, 6, 30))
@@ -305,16 +312,24 @@ class TestTime < Test::Unit::TestCase
t1 = Time.gm(2000)
t2 = t1.getlocal
assert_equal(t1, t2)
+ t3 = t1.getlocal("-02:00")
+ assert_equal(t1, t3)
+ assert_equal(-7200, t3.utc_offset)
t1.localtime
assert_equal(t1, t2)
assert_equal(t1.gmt?, t2.gmt?)
+ assert_equal(t1, t3)
t1 = Time.local(2000)
t2 = t1.getgm
assert_equal(t1, t2)
+ t3 = t1.getlocal("-02:00")
+ assert_equal(t1, t3)
+ assert_equal(-7200, t3.utc_offset)
t1.gmtime
assert_equal(t1, t2)
assert_equal(t1.gmt?, t2.gmt?)
+ assert_equal(t1, t3)
end
def test_asctime