diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-25 03:33:22 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-25 03:33:22 +0000 |
commit | a95be81ea20816d933d5ef1efccdf9d1b71bfe03 (patch) | |
tree | 14d4a76b52d2803000a3c18d224b44e7c281c93a /test | |
parent | ecb837865122577bfb43de55a422599d928d22c2 (diff) | |
download | ruby-a95be81ea20816d933d5ef1efccdf9d1b71bfe03.tar.gz |
Revert "* lib/yaml.rb: Remove Psych::EngineManager [Bug #8344]"
zzak is not the maintainer of yaml.
This reverts commit r46097.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_engine_manager.rb | 47 | ||||
-rw-r--r-- | test/psych/test_yamldbm.rb | 2 | ||||
-rw-r--r-- | test/psych/test_yamlstore.rb | 2 |
3 files changed, 51 insertions, 0 deletions
diff --git a/test/psych/test_engine_manager.rb b/test/psych/test_engine_manager.rb new file mode 100644 index 0000000000..33a67432eb --- /dev/null +++ b/test/psych/test_engine_manager.rb @@ -0,0 +1,47 @@ +require_relative 'helper' +require 'yaml' + +module Psych + class TestEngineManager < TestCase + def test_bad_engine + assert_raises(ArgumentError) do + YAML::ENGINE.yamler = 'foooo' + end + end + + def test_set_psych + YAML::ENGINE.yamler = 'psych' + assert_equal Psych, YAML + assert_equal 'psych', YAML::ENGINE.yamler + end + + A = Struct.new(:name) + + def test_dump_types + YAML::ENGINE.yamler = 'psych' + + assert_to_yaml ::Object.new + assert_to_yaml Time.now + assert_to_yaml Date.today + assert_to_yaml('a' => 'b') + assert_to_yaml A.new('foo') + assert_to_yaml %w{a b} + assert_to_yaml Exception.new('foo') + assert_to_yaml "hello!" + assert_to_yaml :fooo + assert_to_yaml(1..10) + assert_to_yaml(/hello!~/) + assert_to_yaml 1 + assert_to_yaml 1.2 + assert_to_yaml Rational(1, 2) + assert_to_yaml Complex(1, 2) + assert_to_yaml true + assert_to_yaml false + assert_to_yaml nil + end + + def assert_to_yaml obj + assert obj.to_yaml, "#{obj.class} to_yaml works" + end + end +end diff --git a/test/psych/test_yamldbm.rb b/test/psych/test_yamldbm.rb index 23c7c9e564..dba9eee2a9 100644 --- a/test/psych/test_yamldbm.rb +++ b/test/psych/test_yamldbm.rb @@ -13,6 +13,7 @@ module Psych class YAMLDBMTest < TestCase def setup + @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych' @dir = Dir.mktmpdir("rubytest-file") File.chown(-1, Process.gid, @dir) @yamldbm_file = make_tmp_filename("yamldbm") @@ -20,6 +21,7 @@ module Psych end def teardown + YAML::ENGINE.yamler = @engine @yamldbm.clear @yamldbm.close FileUtils.remove_entry_secure @dir diff --git a/test/psych/test_yamlstore.rb b/test/psych/test_yamlstore.rb index 94f1330d37..19471b1e35 100644 --- a/test/psych/test_yamlstore.rb +++ b/test/psych/test_yamlstore.rb @@ -7,6 +7,7 @@ module Psych class YAMLStoreTest < TestCase def setup + @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych' @dir = Dir.mktmpdir("rubytest-file") File.chown(-1, Process.gid, @dir) @yamlstore_file = make_tmp_filename("yamlstore") @@ -14,6 +15,7 @@ module Psych end def teardown + YAML::ENGINE.yamler = @engine FileUtils.remove_entry_secure @dir end |