aboutsummaryrefslogtreecommitdiffstats
path: root/test/psych/test_encoding.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-10 16:22:52 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-10 16:22:52 +0000
commit0de068d03e373cbc95da824c4b5a07910ea20e3f (patch)
treee48e5829ca8b32b8dcd860cb70c87a393fbd3e2b /test/psych/test_encoding.rb
parent9d3b304b0bc0f2e36b61579971dafd83798ab56b (diff)
downloadruby-0de068d03e373cbc95da824c4b5a07910ea20e3f.tar.gz
* ext/psych/parser.c (parse): Return strings encoded as
Encoding.default_internal if set. * test/psych/test_encoding.rb: Tests for encoding change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_encoding.rb')
-rw-r--r--test/psych/test_encoding.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index 9d290f1c0a..bf8318a774 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -29,6 +29,22 @@ module Psych
@utf8 = Encoding.find('UTF-8')
end
+ def test_default_internal
+ before = Encoding.default_internal
+
+ Encoding.default_internal = 'EUC-JP'
+
+ str = "壁に耳あり、障子に目あり"
+ yaml = "--- #{str}"
+ assert_equal @utf8, str.encoding
+
+ @parser.parse str
+ assert_encodings Encoding.find('EUC-JP'), @handler.strings
+ assert_equal str, @handler.strings.first.encode('UTF-8')
+ ensure
+ Encoding.default_internal = before
+ end
+
def test_scalar
@parser.parse("--- a")
assert_encodings @utf8, @handler.strings