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

ruby-changes:2501

From: ko1@a...
Date: 21 Nov 2007 16:40:55 +0900
Subject: [ruby-changes:2501] akr - Ruby:r13992 (trunk): * test/fileutils/fileasserts.rb (assert_equal_timestamp): new assert

akr	2007-11-21 16:40:36 +0900 (Wed, 21 Nov 2007)

  New Revision: 13992

  Modified files:
    trunk/ChangeLog
    trunk/test/fileutils/fileasserts.rb

  Log:
    * test/fileutils/fileasserts.rb (assert_equal_timestamp): new assert
      to test tv_sec only for filestamp resolution portability.
      (assert_same_entry): use assert_same_entry for mtime comparison.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13992&r2=13991
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/fileutils/fileasserts.rb?r1=13992&r2=13991

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13991)
+++ ChangeLog	(revision 13992)
@@ -1,3 +1,9 @@
+Wed Nov 21 16:39:21 2007  Tanaka Akira  <akr@f...>
+
+	* test/fileutils/fileasserts.rb (assert_equal_timestamp): new assert
+	  to test tv_sec only for filestamp resolution portability.
+	  (assert_same_entry): use assert_same_entry for mtime comparison.
+
 Wed Nov 21 14:55:13 2007  Koichi Sasada  <ko1@a...>
 
 	* array.c (rb_ary_permutation): add gc guard codes.
Index: test/fileutils/fileasserts.rb
===================================================================
--- test/fileutils/fileasserts.rb	(revision 13991)
+++ test/fileutils/fileasserts.rb	(revision 13992)
@@ -17,7 +17,7 @@
         b = File.stat(to)
         assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}"
         #assert_equal a.atime, b.atime
-        assert_equal_time a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
+        assert_equal_timestamp a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
         assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}"
         assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}"
       end
@@ -78,6 +78,23 @@
         }
       end
 
+      def assert_equal_timestamp(expected, actual, message=nil)
+        _wrap_assertion {
+	  expected_str = expected.to_s
+	  actual_str = actual.to_s
+	  if expected_str == actual_str
+	    expected_str << " (nsec=#{expected.nsec})"
+	    actual_str << " (nsec=#{actual.nsec})"
+	  end
+	  full_message = build_message(message, <<EOT)
+<#{expected_str}> expected but was
+<#{actual_str}>.
+EOT
+          # subsecond timestamp is not portable. 
+	  assert_block(full_message) { expected.tv_sec == actual.tv_sec }
+        }
+      end
+
     end
   end
 end

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

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