mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/psych/helper.rb: envutil is not available outside Ruby, so
port the functions from envutil to the test helper. * test/psych/test_deprecated.rb: ditto * test/psych/test_encoding.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0b8f727d7b
commit
d7f06a665c
4 changed files with 42 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
Wed May 15 02:06:35 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* test/psych/helper.rb: envutil is not available outside Ruby, so
|
||||
port the functions from envutil to the test helper.
|
||||
|
||||
* test/psych/test_deprecated.rb: ditto
|
||||
|
||||
* test/psych/test_encoding.rb: ditto
|
||||
|
||||
Wed May 15 00:42:54 2013 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* signal.c: need to include unistd.h for write(2).
|
||||
|
|
|
@ -3,10 +3,38 @@ require 'stringio'
|
|||
require 'tempfile'
|
||||
require 'date'
|
||||
require 'psych'
|
||||
require_relative '../ruby/envutil'
|
||||
|
||||
module Psych
|
||||
class TestCase < MiniTest::Unit::TestCase
|
||||
def self.suppress_warning
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
yield
|
||||
ensure
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
def with_default_external(enc)
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
origenc, Encoding.default_external = Encoding.default_external, enc
|
||||
$VERBOSE = verbose
|
||||
yield
|
||||
ensure
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
Encoding.default_external = origenc
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
def with_default_internal(enc)
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
origenc, Encoding.default_internal = Encoding.default_internal, enc
|
||||
$VERBOSE = verbose
|
||||
yield
|
||||
ensure
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
Encoding.default_internal = origenc
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
#
|
||||
# Convert between Psych and the object to verify correct parsing and
|
||||
# emitting
|
||||
|
|
|
@ -147,7 +147,7 @@ module Psych
|
|||
end
|
||||
|
||||
class YamlAs
|
||||
EnvUtil.suppress_warning do
|
||||
TestCase.suppress_warning do
|
||||
psych_yaml_as 'helloworld' # this should be yaml_as but to avoid syck
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,8 +110,8 @@ module Psych
|
|||
end
|
||||
|
||||
def test_to_yaml_is_valid
|
||||
EnvUtil.with_default_external(Encoding::US_ASCII) do
|
||||
EnvUtil.with_default_internal(nil) do
|
||||
with_default_external(Encoding::US_ASCII) do
|
||||
with_default_internal(nil) do
|
||||
s = "こんにちは!"
|
||||
# If no encoding is specified, use UTF-8
|
||||
assert_equal Encoding::UTF_8, Psych.dump(s).encoding
|
||||
|
@ -182,7 +182,7 @@ module Psych
|
|||
end
|
||||
|
||||
def test_default_internal
|
||||
EnvUtil.with_default_internal(Encoding::EUC_JP) do
|
||||
with_default_internal(Encoding::EUC_JP) do
|
||||
str = "壁に耳あり、障子に目あり"
|
||||
assert_equal @utf8, str.encoding
|
||||
|
||||
|
|
Loading…
Reference in a new issue