summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-25 23:24:33 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-25 23:24:33 +0000
commit4544b3824c8ce74e0a92c58a3167f900904f506b (patch)
treea1a44d418b10817e48074fed532a8969a07a5a17 /test
parenta6e30a87140512445892d464b841a8ef60e0d012 (diff)
* time.c (strftimev): Make Time#to_s default to US-ASCII encoding but
respect Encoding.default_internal. [ruby-core:39092] * test/ruby/test_time.rb (class TestTime): Corresponding test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_time.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 1f07a8249c..32d3b976d0 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -15,6 +15,22 @@ class TestTime < Test::Unit::TestCase
$VERBOSE = @verbose
end
+ def test_to_s_default_encoding
+ before = Encoding.default_internal
+ Encoding.default_internal = nil
+ assert_equal Encoding::US_ASCII, Time.now.to_s.encoding
+ ensure
+ Encoding.default_internal = before
+ end
+
+ def test_to_s_transcoding
+ before = Encoding.default_internal
+ Encoding.default_internal = Encoding::UTF_8
+ assert_equal Encoding::UTF_8, Time.now.to_s.encoding
+ ensure
+ Encoding.default_internal = before
+ end
+
def test_new
assert_equal(Time.utc(2000,2,10), Time.new(2000,2,10, 11,0,0, 3600*11))
assert_equal(Time.utc(2000,2,10), Time.new(2000,2,9, 13,0,0, -3600*11))