diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-03 21:50:47 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-03 21:50:47 +0000 |
commit | eb71e5cd67f4ce4da5ba331f93a8e36c65457b94 (patch) | |
tree | 1df66113ae7340e2b928839b3f09dbf8dcfb3d73 /test | |
parent | ca926ad017a804817b9a2e5389196f9acf9d9b68 (diff) | |
download | ruby-eb71e5cd67f4ce4da5ba331f93a8e36c65457b94.tar.gz |
* lib/yaml: Moved to ext/syck/lib, Syck only uses Syck constant.
* lib/yaml.rb: Added an engine manager for choosing YAML engine.
* ext/syck/lib/syck/rubytypes.rb: squashed warnings when using Psych
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_engine_manager.rb | 57 | ||||
-rw-r--r-- | test/yaml/test_engine_manager.rb | 3 | ||||
-rw-r--r-- | test/yaml/test_yaml.rb | 2 | ||||
-rw-r--r-- | test/yaml/test_yamlstore.rb | 2 |
4 files changed, 62 insertions, 2 deletions
diff --git a/test/psych/test_engine_manager.rb b/test/psych/test_engine_manager.rb new file mode 100644 index 0000000000..8bd7d6c1da --- /dev/null +++ b/test/psych/test_engine_manager.rb @@ -0,0 +1,57 @@ +require_relative 'helper' +require 'yaml' + +module Psych + class TestEngineManager < TestCase + def teardown + YAML::ENGINE.yamler = 'syck' + end + + 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 + + def test_set_syck + YAML::ENGINE.yamler = 'syck' + assert_equal Syck, YAML + assert_equal 'syck', 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/yaml/test_engine_manager.rb b/test/yaml/test_engine_manager.rb new file mode 100644 index 0000000000..529fc49d38 --- /dev/null +++ b/test/yaml/test_engine_manager.rb @@ -0,0 +1,3 @@ +require 'test/unit' +require 'yaml' + diff --git a/test/yaml/test_yaml.rb b/test/yaml/test_yaml.rb index bda68cccf3..606c2676f1 100644 --- a/test/yaml/test_yaml.rb +++ b/test/yaml/test_yaml.rb @@ -4,7 +4,7 @@ # require 'test/unit' require 'yaml' -require 'yaml/ypath' +require 'syck/ypath' # [ruby-core:01946] module YAML_Tests diff --git a/test/yaml/test_yamlstore.rb b/test/yaml/test_yamlstore.rb index 69302095e5..1374d32d24 100644 --- a/test/yaml/test_yamlstore.rb +++ b/test/yaml/test_yamlstore.rb @@ -1,5 +1,5 @@ require 'test/unit' -require 'yaml/store' +require 'syck/store' class YAMLStoreTest < Test::Unit::TestCase def setup |