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

ruby-changes:35369

From: nobu <ko1@a...>
Date: Mon, 8 Sep 2014 17:03:36 +0900 (JST)
Subject: [ruby-changes:35369] nobu:r47451 (trunk): test_time_tz.rb: right timezone

nobu	2014-09-08 17:03:21 +0900 (Mon, 08 Sep 2014)

  New Revision: 47451

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

  Log:
    test_time_tz.rb: right timezone
    
    * test/ruby/test_time_tz.rb (has_right_tz): check if right
      timezones are installed.

  Modified files:
    trunk/test/ruby/test_time_tz.rb
Index: test/ruby/test_time_tz.rb
===================================================================
--- test/ruby/test_time_tz.rb	(revision 47450)
+++ test/ruby/test_time_tz.rb	(revision 47451)
@@ -6,33 +6,39 @@ class TestTimeTZ < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L6
   force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes"
   case RUBY_PLATFORM
   when /linux/
-    # has_right_tz = false
     force_tz_test = true
   when /darwin|freebsd/
-    has_right_tz = false
     has_lisbon_tz = false
     force_tz_test = true
   end
 
   if force_tz_test
-    def with_tz(tz)
-      old = ENV["TZ"]
-      begin
-        ENV["TZ"] = tz
-        yield
-      ensure
-        ENV["TZ"] = old
+    module Util
+      def with_tz(tz)
+        old = ENV["TZ"]
+        begin
+          ENV["TZ"] = tz
+          yield
+        ensure
+          ENV["TZ"] = old
+        end
       end
     end
   else
-    def with_tz(tz)
-      if ENV["TZ"] == tz
-        yield
+    module Util
+      def with_tz(tz)
+        if ENV["TZ"] == tz
+          yield
+        end
       end
     end
   end
 
   module Util
+    def have_tz_offset(tz)
+      with_tz(tz) {!Time.now.utc_offset.zero?}
+    end
+
     def format_gmtoff(gmtoff, colon=false)
       if gmtoff < 0
         expected = "-"
@@ -75,6 +81,9 @@ class TestTimeTZ < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time_tz.rb#L81
   include Util
   extend Util
 
+  has_right_tz &&= have_tz_offset("right/America/Los_Angeles")
+  has_lisbon_tz &&= have_tz_offset("Europe/Lisbon")
+
   def time_to_s(t)
     t.to_s
   end

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

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