aboutsummaryrefslogtreecommitdiffstats
path: root/test/psych/test_encoding.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-02 02:14:21 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-02 02:14:21 +0000
commit7a77e124882f925fe8c7e51a28bac7f15e8ad868 (patch)
tree8bd3556fe6dd94c3289071ccf69c0f6d2c01825f /test/psych/test_encoding.rb
parent0fb23a9449fbdb858be4df90e84214cf0916845d (diff)
downloadruby-7a77e124882f925fe8c7e51a28bac7f15e8ad868.tar.gz
Suppress warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_encoding.rb')
-rw-r--r--test/psych/test_encoding.rb40
1 files changed, 15 insertions, 25 deletions
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index 980ca5c698..2cddd5983f 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -114,19 +114,14 @@ module Psych
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
+ EnvUtil.with_default_external(Encoding::US_ASCII) do
+ EnvUtil.with_default_internal(nil) do
+ 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))
+ end
+ end
end
def test_start_mapping
@@ -191,19 +186,14 @@ module Psych
end
def test_default_internal
- before = Encoding.default_internal
-
- Encoding.default_internal = 'EUC-JP'
+ EnvUtil.with_default_internal(Encoding::EUC_JP) do
+ str = "壁に耳あり、障子に目あり"
+ assert_equal @utf8, str.encoding
- 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
+ @parser.parse str
+ assert_encodings Encoding::EUC_JP, @handler.strings
+ assert_equal str, @handler.strings.first.encode('UTF-8')
+ end
end
def test_scalar