Permalink
Browse files

sync with ruby trunk

  • Loading branch information...
1 parent edf05c9 commit b4537454d9da6e901dcacf4c4e36de08095f79a3 @tenderlove tenderlove committed Apr 5, 2013
View
@@ -3,6 +3,7 @@
require 'tempfile'
require 'date'
require 'psych'
+require_relative '../ruby/envutil'
module Psych
class TestCase < MiniTest::Unit::TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
class ObjectWithInstanceVariables
attr_accessor :var1, :var2
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestArray < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
###
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestClass < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestCoder < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'date'
module Psych
@@ -1,8 +1,9 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestDeprecated < TestCase
def teardown
+ $VERBOSE = @orig_verbose
Psych.domain_types.clear
end
@@ -27,6 +28,7 @@ def to_yaml opts = {}
def setup
@qe = QuickEmitter.new
+ @orig_verbose, $VERBOSE = $VERBOSE, false
end
def test_quick_emit
@@ -145,7 +147,9 @@ def test_coder_scalar
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
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestDocument < TestCase
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestEmitter < TestCase
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestEncoding < TestCase
@@ -114,19 +114,14 @@ def test_emit_alias
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 @@ def test_emitter_encoding
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
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'yaml'
module Psych
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestException < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestHash < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestJSONTree < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestMergeKeys < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestNil < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
###
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'bigdecimal'
module Psych
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class Tagged
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestObjectReferences < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestOmap < TestCase
@@ -1,6 +1,6 @@
# coding: utf-8
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestParser < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'stringio'
require 'tempfile'
@@ -68,6 +68,7 @@ def test_dump_file
assert_equal io, Psych.dump(hash, io)
io.rewind
assert_equal Psych.dump(hash), io.read
+ io.close(true)
end
end
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestScalar < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'date'
module Psych
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestSerializeSubclasses < TestCase
View
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestSet < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestStream < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestString < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
class PsychStructWithIvar < Struct.new(:foo)
attr_reader :bar
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestSymbol < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestStringTainted < TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestToYamlProperties < MiniTest::Unit::TestCase
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
module Psych
class TestTreeBuilder < TestCase
View
@@ -2,7 +2,7 @@
# vim:sw=4:ts=4
# $Id$
#
-require 'psych/helper'
+require_relative 'helper'
require 'ostruct'
# [ruby-core:01946]
@@ -1,6 +1,6 @@
# -*- coding: UTF-8 -*-
-require 'psych/helper'
+require_relative 'helper'
require 'tmpdir'
begin
@@ -1,4 +1,4 @@
-require 'psych/helper'
+require_relative 'helper'
require 'yaml/store'
require 'tmpdir'

1 comment on commit b453745

Member

zzak commented on b453745 Apr 5, 2013

You could say this sync was relative?

Please sign in to comment.