aboutsummaryrefslogtreecommitdiffstats
path: root/test/psych/test_encoding.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-24 21:14:44 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-24 21:14:44 +0000
commit34f6671d68a3fc6d94a7ed6954b71615735fa83b (patch)
tree019f130be7623c0624b349b0399b299f6d9c2fc2 /test/psych/test_encoding.rb
parent8b8c7fd386022f30f846ce7fd4c8224d61118b57 (diff)
downloadruby-34f6671d68a3fc6d94a7ed6954b71615735fa83b.tar.gz
* ext/psych/lib/psych/nodes/node.rb: default `to_yaml` encoding to be
UTF-8. * test/psych/test_encoding.rb: test yaml dump encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33052 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 029ff75ed9..a341c47859 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -40,6 +40,22 @@ module Psych
assert_match(/alias value/, e.message)
end
+ def test_to_yaml_is_valid
+ ext_before = Encoding.default_external
+ int_before = Encoding.default_internal
+
+ Encoding.default_external = Encoding::US_ASCII
+ Encoding.default_internal = nil
+
+ s = "こんにちは!"
+ # If no encoding is specified, use UTF-8
+ assert_equal Encoding::UTF_8, Psych.dump(s).encoding
+ assert_equal s, Psych.load(Psych.dump(s))
+ ensure
+ Encoding.default_external = ext_before
+ Encoding.default_internal = int_before
+ end
+
def test_start_mapping
foo = 'foo'
bar = 'バー'