From 97c5a33f7e994b141a84e6628ed2e60277c9785b Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 25 Sep 2017 06:20:10 +0000 Subject: 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 --- test/ruby/test_time.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby/test_time.rb') 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) -- cgit v1.2.3