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

ruby-changes:16605

From: yugui <ko1@a...>
Date: Sat, 10 Jul 2010 13:04:50 +0900 (JST)
Subject: [ruby-changes:16605] Ruby:r28598 (ruby_1_9_2): merges r28531 from trunk into ruby_1_9_2.

yugui	2010-07-10 13:01:24 +0900 (Sat, 10 Jul 2010)

  New Revision: 28598

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

  Log:
    merges r28531 from trunk into ruby_1_9_2.
    --
    * ext/psych/lib/psych/visitors/yaml_tree.rb (visit_Time): use
      Time#nsec to accurately serialize time objects. [ruby-core:29233]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/ext/psych/lib/psych/visitors/yaml_tree.rb
    branches/ruby_1_9_2/test/psych/visitors/test_to_ruby.rb
    branches/ruby_1_9_2/test/psych/visitors/test_yaml_tree.rb

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28597)
+++ ruby_1_9_2/ChangeLog	(revision 28598)
@@ -1,3 +1,8 @@
+Sat Jul  3 09:13:55 2010  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/yaml_tree.rb (visit_Time): use
+	  Time#nsec to accurately serialize time objects. [ruby-core:29233]
+
 Tue Jul  6 00:34:50 2010  Yusuke Endoh  <mame@t...>
 
 	* vm.c (thread_free): free altstack to prevent memory leak.  a patch
Index: ruby_1_9_2/ext/psych/lib/psych/visitors/yaml_tree.rb
===================================================================
--- ruby_1_9_2/ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 28597)
+++ ruby_1_9_2/ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 28598)
@@ -126,9 +126,9 @@
       def visit_Time o
         formatted = o.strftime("%Y-%m-%d %H:%M:%S")
         if o.utc?
-          formatted += ".%06dZ" % [o.usec]
+          formatted += ".%06dZ" % [o.nsec]
         else
-          formatted += ".%06d %+.2d:00" % [o.usec, o.gmt_offset / 3600]
+          formatted += ".%06d %+.2d:00" % [o.nsec, o.gmt_offset / 3600]
         end
 
         @emitter.scalar formatted, nil, nil, true, false, Nodes::Scalar::ANY
Index: ruby_1_9_2/test/psych/visitors/test_yaml_tree.rb
===================================================================
--- ruby_1_9_2/test/psych/visitors/test_yaml_tree.rb	(revision 28597)
+++ ruby_1_9_2/test/psych/visitors/test_yaml_tree.rb	(revision 28598)
@@ -54,7 +54,7 @@
 
       def test_time
         t = Time.now
-        assert_in_delta t, Psych.load(Psych.dump(t)), 0.000001
+        assert_equal t, Psych.load(Psych.dump(t))
       end
 
       def test_date
Index: ruby_1_9_2/test/psych/visitors/test_to_ruby.rb
===================================================================
--- ruby_1_9_2/test/psych/visitors/test_to_ruby.rb	(revision 28597)
+++ ruby_1_9_2/test/psych/visitors/test_to_ruby.rb	(revision 28598)
@@ -113,25 +113,25 @@
       def test_time
         now = Time.now
         formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
-          ".%06d %+.2d:00" % [now.usec, now.gmt_offset / 3600]
+          ".%06d %+.2d:00" % [now.nsec, now.gmt_offset / 3600]
 
-        assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+        assert_equal now, Nodes::Scalar.new(formatted).to_ruby
       end
 
       def test_time_utc
         now = Time.now.utc
         formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
-          ".%06dZ" % [now.usec]
+          ".%06dZ" % [now.nsec]
 
-        assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+        assert_equal now, Nodes::Scalar.new(formatted).to_ruby
       end
 
       def test_time_utc_no_z
         now = Time.now.utc
         formatted = now.strftime("%Y-%m-%d %H:%M:%S") +
-          ".%06d" % [now.usec]
+          ".%06d" % [now.nsec]
 
-        assert_in_delta now, Nodes::Scalar.new(formatted).to_ruby, 0.000001
+        assert_equal now, Nodes::Scalar.new(formatted).to_ruby
       end
 
       def test_date

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

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