[前][次][番号順一覧][スレッド一覧]

ruby-changes:32120

From: nobu <ko1@a...>
Date: Sat, 14 Dec 2013 13:17:07 +0900 (JST)
Subject: [ruby-changes:32120] nobu:r44199 (trunk): Additional test coverage to DateTime comparison (sub millisecond).

nobu	2013-12-14 13:17:03 +0900 (Sat, 14 Dec 2013)

  New Revision: 44199

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44199

  Log:
    Additional test coverage to DateTime comparison (sub millisecond).

  Modified files:
    trunk/test/date/test_date.rb
Index: test/date/test_date.rb
===================================================================
--- test/date/test_date.rb	(revision 44198)
+++ test/date/test_date.rb	(revision 44199)
@@ -141,4 +141,13 @@ class TestDate < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/date/test_date.rb#L141
     assert_instance_of(String, d.to_s)
   end
 
+  def test_submillisecond_comparison
+    d1 = DateTime.new(2013, 12, 6, 0, 0, Rational(1, 10000))
+    d2 = DateTime.new(2013, 12, 6, 0, 0, Rational(2, 10000))
+    # d1 is 0.0001s earlier than d2
+    assert_equal(-1, d1 <=> d2)
+    assert_equal(0, d1 <=> d1)
+    assert_equal(1, d2 <=> d1)
+  end
+
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]