Skip to content

Commit

Permalink
test_time.rb: encoding of Time#zone
Browse files Browse the repository at this point in the history
* test/ruby/test_time.rb (assert_zone_encoding): encoding of
  Time#zone is not locale, but the default internal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jul 23, 2014
1 parent 98a2dfe commit 87c8901
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/ruby/test_time.rb
Expand Up @@ -517,8 +517,15 @@ def test_to_s
assert_equal(Time.at(946684800).getlocal.to_s, Time.at(946684800).to_s)
end

def assert_zone_encoding(time)
zone = time.zone
assert_predicate(zone, :valid_encoding?)
enc = Encoding.default_internal || Encoding.find('locale')
assert_equal(enc, zone.encoding)
end

def test_zone
assert_equal(Encoding.find('locale'), Time.now.zone.encoding)
assert_zone_encoding Time.now
end

def test_plus_minus_succ
Expand Down Expand Up @@ -567,7 +574,7 @@ def test_readers
assert_equal(1, t2000.yday)
assert_equal(false, t2000.isdst)
assert_equal("UTC", t2000.zone)
assert_equal(Encoding.find("locale"), t2000.zone.encoding)
assert_zone_encoding(t2000)
assert_equal(0, t2000.gmt_offset)
assert_not_predicate(t2000, :sunday?)
assert_not_predicate(t2000, :monday?)
Expand All @@ -589,7 +596,7 @@ def test_readers
assert_equal(t.yday, Time.at(946684800).yday)
assert_equal(t.isdst, Time.at(946684800).isdst)
assert_equal(t.zone, Time.at(946684800).zone)
assert_equal(Encoding.find("locale"), Time.at(946684800).zone.encoding)
assert_zone_encoding(Time.at(946684800))
assert_equal(t.gmt_offset, Time.at(946684800).gmt_offset)
assert_equal(t.sunday?, Time.at(946684800).sunday?)
assert_equal(t.monday?, Time.at(946684800).monday?)
Expand Down

0 comments on commit 87c8901

Please sign in to comment.