diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-25 06:20:10 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-25 06:20:10 +0000 |
commit | 97c5a33f7e994b141a84e6628ed2e60277c9785b (patch) | |
tree | 7abcef91e1ff4d60af3b51e52cd4c0c261d82ff8 /test/ruby | |
parent | 1aad241ae87bbcc38f542ae543d021a6e489beaf (diff) | |
download | ruby-97c5a33f7e994b141a84e6628ed2e60277c9785b.tar.gz |
Time#at receives 3rd argument which specifies the unit of 2nd argument [Feature #13919]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_time.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index c92aafc149..faeff8ded3 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -236,6 +236,17 @@ class TestTime < Test::Unit::TestCase assert_equal(1, Time.at(0, 0.001).nsec) end + def test_at_with_unit + assert_equal(123456789, Time.at(0, 123456789, :nanosecond).nsec) + assert_equal(123456789, Time.at(0, 123456789, :nsec).nsec) + assert_equal(123456000, Time.at(0, 123456, :microsecond).nsec) + assert_equal(123456000, Time.at(0, 123456, :usec).nsec) + assert_equal(123000000, Time.at(0, 123, :millisecond).nsec) + assert_raise(ArgumentError){ Time.at(0, 1, 2) } + assert_raise(ArgumentError){ Time.at(0, 1, :invalid) } + assert_raise(ArgumentError){ Time.at(0, 1, nil) } + end + def test_at_rational assert_equal(1, Time.at(Rational(1,1) / 1000000000).nsec) assert_equal(1, Time.at(1167609600 + Rational(1,1) / 1000000000).nsec) |