summaryrefslogtreecommitdiff
path: root/test/psych/test_psych.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-24 04:11:27 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-24 04:11:27 +0000
commit7309f9cc007f1cc05eb70967356069161d867356 (patch)
tree6dcfc346ff9055c7d938b8f01be917c6ed1edd98 /test/psych/test_psych.rb
parent655b2ade4984f8d0ad6c76d6eff35262ad7d2619 (diff)
* ext/psych/lib/psych.rb: supporting deprecated syck method
add_ruby_type * ext/psych/lib/psych/visitors/to_ruby.rb: ditto * test/psych/test_deprecated.rb: ditto * test/psych/test_psych.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_psych.rb')
-rw-r--r--test/psych/test_psych.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 91c67b1..78f022c 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -4,6 +4,10 @@ require 'stringio'
require 'tempfile'
class TestPsych < Psych::TestCase
+ def teardown
+ Psych.domain_types.clear
+ end
+
def test_load_argument_error
assert_raises(TypeError) do
Psych.load nil
@@ -56,7 +60,7 @@ class TestPsych < Psych::TestCase
Psych.add_builtin_type 'omap', do |type, val|
got = val
end
- Psych.load('--- !omap hello')
+ Psych.load('--- !!omap hello')
assert_equal 'hello', got
ensure
Psych.remove_type 'omap'
@@ -98,4 +102,21 @@ class TestPsych < Psych::TestCase
assert_equal false, Psych.load('')
assert_equal false, Psych.parse('')
end
+
+ def test_callbacks
+ types = []
+ appender = lambda { |*args| types << args }
+
+ Psych.add_builtin_type('foo', &appender)
+ Psych.add_domain_type('example.com,2002', 'foo', &appender)
+ Psych.load <<-eoyml
+- !tag:yaml.org,2002:foo bar
+- !tag:example.com,2002:foo bar
+ eoyml
+
+ assert_equal [
+ ["tag:yaml.org,2002:foo", "bar"],
+ ["tag:example.com,2002:foo", "bar"]
+ ], types
+ end
end