diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-18 03:52:01 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-18 03:52:01 +0000 |
commit | 8cf05741bc4d94ba2b0aa53d876738b7fd5fc747 (patch) | |
tree | cd2c2554dfdfeedd1914c3357e95f8c67e46c96a /test/psych/test_string.rb | |
parent | 99840a64b6687f3ae229f779152c7a37f7046d0b (diff) | |
download | ruby-8cf05741bc4d94ba2b0aa53d876738b7fd5fc747.tar.gz |
* ext/psych/lib/psych/visitors/to_ruby.rb: Added support for loading
subclasses of String with ivars
* ext/psych/lib/psych/visitors/yaml_tree.rb: Added support for dumping
subclasses of String with ivars
* test/psych/test_string.rb: corresponding tests
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_string.rb')
-rw-r--r-- | test/psych/test_string.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index cffc12163b..c7d5c60623 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -2,6 +2,31 @@ require 'psych/helper' module Psych class TestString < TestCase + class X < String + end + + class Y < String + attr_accessor :val + end + + def test_backwards_with_syck + x = Psych.load "--- !str:#{X.name} foo\n\n" + assert_equal X, x.class + assert_equal 'foo', x + end + + def test_empty_subclass + assert_match "!ruby/string:#{X}", Psych.dump(X.new) + x = Psych.load Psych.dump X.new + assert_equal X, x.class + end + + def test_subclass_with_attributes + y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1} + assert_equal Y, y.class + assert_equal 1, y.val + end + def test_string_with_base_60 yaml = Psych.dump '01:03:05' assert_match "'01:03:05'", yaml |