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

ruby-changes:13388

From: akr <ko1@a...>
Date: Tue, 29 Sep 2009 22:22:46 +0900 (JST)
Subject: [ruby-changes:13388] Ruby:r25158 (trunk): * lib/test/unit/assertions.rb (assert_equal): use Time#subsec if nsec

akr	2009-09-29 22:22:27 +0900 (Tue, 29 Sep 2009)

  New Revision: 25158

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

  Log:
    * lib/test/unit/assertions.rb (assert_equal): use Time#subsec if nsec
      is not enough to distinguish arguments.

  Modified files:
    trunk/ChangeLog
    trunk/lib/test/unit/assertions.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25157)
+++ ChangeLog	(revision 25158)
@@ -1,3 +1,8 @@
+Tue Sep 29 22:19:36 2009  Tanaka Akira  <akr@f...>
+
+	* lib/test/unit/assertions.rb (assert_equal): use Time#subsec if nsec
+	  is not enough to distinguish arguments.
+
 Tue Sep 29 21:16:35 2009  NARUSE, Yui  <naruse@r...>
 
 	* io.c (rb_scan_open_args): add UTF8-MAC to no-convertion encoding.
Index: lib/test/unit/assertions.rb
===================================================================
--- lib/test/unit/assertions.rb	(revision 25157)
+++ lib/test/unit/assertions.rb	(revision 25158)
@@ -67,8 +67,16 @@
               exp_str = "%\#.#{Float::DIG+2}g" % exp
               act_str = "%\#.#{Float::DIG+2}g" % act
             elsif exp.is_a?(Time) && act.is_a?(Time)
-              exp_comment = " (nsec=#{exp.nsec})"
-              act_comment = " (nsec=#{act.nsec})"
+              if exp.subsec * 1000_000_000 == exp.nsec
+                exp_comment = " (#{exp.nsec}[ns])"
+              else
+                exp_comment = " (subsec=#{exp.subsec})"
+              end
+              if act.subsec * 1000_000_000 == act.nsec
+                act_comment = " (#{act.nsec}[ns])"
+              else
+                act_comment = " (subsec=#{act.subsec})"
+              end
             elsif exp.class != act.class
               # a subclass of Range, for example.
               exp_comment = " (#{exp.class})"

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

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