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

ruby-changes:30520

From: eregon <ko1@a...>
Date: Sat, 17 Aug 2013 23:25:39 +0900 (JST)
Subject: [ruby-changes:30520] eregon:r42599 (trunk): * test/ruby/test_time.rb: use the in_timezone() helper

eregon	2013-08-17 23:25:34 +0900 (Sat, 17 Aug 2013)

  New Revision: 42599

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

  Log:
    * test/ruby/test_time.rb: use the in_timezone() helper
      and define it at the top with other helpers.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_time.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42598)
+++ ChangeLog	(revision 42599)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug 17 23:25:19 2013  Benoit Daloze  <eregontp@g...>
+
+	* test/ruby/test_time.rb: use the in_timezone() helper
+	  and define it at the top with other helpers.
+
 Sat Aug 17 22:20:47 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* time.c (time_mload): ignore auxiliary data, offset and zone, if
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 42598)
+++ test/ruby/test_time.rb	(revision 42599)
@@ -15,6 +15,15 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L15
     $VERBOSE = @verbose
   end
 
+  def in_timezone(zone)
+    orig_zone = ENV['TZ']
+
+    ENV['TZ'] = zone
+    yield
+  ensure
+    ENV['TZ'] = orig_zone
+  end
+
   def no_leap_seconds?
     # 1972-06-30T23:59:60Z is the first leap second.
     Time.utc(1972, 7, 1, 0, 0, 0) - Time.utc(1972, 6, 30, 23, 59, 59) == 1
@@ -291,18 +300,15 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L300
   end
 
   def test_marshal_zone
-    orig_zone = ENV['TZ']
-
     t = Time.utc(2013, 2, 24)
     assert_equal('UTC', t.zone)
     assert_equal('UTC', Marshal.load(Marshal.dump(t)).zone)
 
-    ENV['TZ'] = 'JST-9'
-    t = Time.local(2013, 2, 24)
-    assert_equal('JST', Time.local(2013, 2, 24).zone)
-    assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
-  ensure
-    ENV['TZ'] = orig_zone
+    in_timezone('JST-9') do
+      t = Time.local(2013, 2, 24)
+      assert_equal('JST', Time.local(2013, 2, 24).zone)
+      assert_equal('JST', Marshal.load(Marshal.dump(t)).zone)
+    end
   end
 
   def test_marshal_to_s
@@ -312,15 +318,6 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L318
       "[ruby-dev:44827] [Bug #5586]")
   end
 
-  def in_timezone(zone)
-    orig_zone = ENV['TZ']
-
-    ENV['TZ'] = zone
-    yield
-  ensure
-    ENV['TZ'] = orig_zone
-  end
-
   Bug8795 = '[ruby-core:56648] [Bug #8795]'
 
   def test_marshal_broken_offset

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

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