From 7a77e124882f925fe8c7e51a28bac7f15e8ad868 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 2 Apr 2013 02:14:21 +0000 Subject: Suppress warnings git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/helper.rb | 1 + test/psych/test_deprecated.rb | 6 +++++- test/psych/test_encoding.rb | 40 +++++++++++++++------------------------- 3 files changed, 21 insertions(+), 26 deletions(-) (limited to 'test/psych') diff --git a/test/psych/helper.rb b/test/psych/helper.rb index f5800303fd..0aae69971e 100644 --- a/test/psych/helper.rb +++ b/test/psych/helper.rb @@ -3,6 +3,7 @@ require 'stringio' require 'tempfile' require 'date' require 'psych' +require_relative '../ruby/envutil' module Psych class TestCase < MiniTest::Unit::TestCase diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb index 6d35aeddd7..1d853e1371 100644 --- a/test/psych/test_deprecated.rb +++ b/test/psych/test_deprecated.rb @@ -3,6 +3,7 @@ require_relative 'helper' module Psych class TestDeprecated < TestCase def teardown + $VERBOSE = @orig_verbose Psych.domain_types.clear end @@ -27,6 +28,7 @@ module Psych def setup @qe = QuickEmitter.new + @orig_verbose, $VERBOSE = $VERBOSE, false end def test_quick_emit @@ -145,7 +147,9 @@ module Psych end class YamlAs - psych_yaml_as 'helloworld' # this should be yaml_as but to avoid syck + EnvUtil.suppress_warning do + psych_yaml_as 'helloworld' # this should be yaml_as but to avoid syck + end end def test_yaml_as 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 -- cgit v1.2.3