diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 21:18:44 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 21:18:44 +0000 |
commit | 497e61ccba4d77e3241f8729c777b785ef635e8d (patch) | |
tree | b7a9a0cece09cf552031a35c61a81a9df4542c9e /test/psych | |
parent | bad0b9d807455e2c3dacae12b0c33b7d2c95991a (diff) |
* 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/branches/ruby_1_9_3@33053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/test_encoding.rb | 16 |
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 = 'バー' |