summaryrefslogtreecommitdiff
path: root/test
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
parent0fb23a9449fbdb858be4df90e84214cf0916845d (diff)
Suppress warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/psych/helper.rb1
-rw-r--r--test/psych/test_deprecated.rb6
-rw-r--r--test/psych/test_encoding.rb40
3 files changed, 21 insertions, 26 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
index f5800303fd0..0aae69971e5 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 6d35aeddd7e..1d853e13711 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 980ca5c6987..2cddd5983fb 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