Bug #4297: test_time in ruby/test/psych/test_json_tree.rb makes test failure
http://redmine.ruby-lang.org/issues/show/4297

Author: Motohiro KOSAKI
Status: Assigned, Priority: Normal
Category: lib, Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-01-20 trunk 30611) [x86_64-linux]

Recently ruby trunk + linux increase one test failure.

--------------------------------------------------------------------------------
  1) Failure:
test_time(Psych::TestJSONTree) [/home/kosaki/linux/ruby-svn/ruby/test/psych/test_json_tree.rb:45]:
Expected "{\"a\": \"2010-10-10 07:00:00.000000000Z\"}\n", not "{\"a\": \"2010-10-09 15:00:00.000000000Z\"}\n".
--------------------------------------------------------------------------------


Becuase the test are using Time.new and it depend on timezone. 

--------------------------------------------------------------------------------
    def test_time
      time = Time.new(2010, 10, 10).utc
      assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n", Psych.to_json({'a' => time })
    end
--------------------------------------------------------------------------------

note: I'm living in japan timezones.

So, It shold be timezone independent.


% svn diff
Index: test/psych/test_json_tree.rb
===================================================================
--- test/psych/test_json_tree.rb        (revision 30611)
+++ test/psych/test_json_tree.rb        (working copy)
@@ -41,8 +41,8 @@
     end

     def test_time
-      time = Time.new(2010, 10, 10).utc
-      assert_equal "{\"a\": \"2010-10-10 07:00:00.000000000Z\"}\n", Psych.to_json({'a' => time })
+      time = Time.utc(2010, 10, 10).utc
+      assert_equal "{\"a\": \"2010-10-10 00:00:00.000000000Z\"}\n", Psych.to_json({'a' => time })
     end

     def test_datetime


----------------------------------------
http://redmine.ruby-lang.org