diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-15 13:14:04 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-15 13:14:04 -0700 |
commit | 620fc6d749f0e94f7b433af9419927039ca1bfa4 (patch) | |
tree | cc94511ba5b51752ad3806ae77d81c07e960f911 /test | |
parent | 5be67a387507958aa2e7c5b35035bd1941c0ac1b (diff) | |
download | psych-620fc6d749f0e94f7b433af9419927039ca1bfa4.zip |
* ext/psych/lib/psych/visitors/to_ruby.rb: fix a bug with string
subclass dumping and loading.
* test/psych/test_array.rb: pertinent tests
* test/psych/test_string.rb: ditto
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_array.rb | 10 | ||||
-rw-r--r-- | test/psych/test_string.rb | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb index 9eedbb4..747fe95 100644 --- a/test/psych/test_array.rb +++ b/test/psych/test_array.rb @@ -14,6 +14,16 @@ module Psych @list = [{ :a => 'b' }, 'foo'] end + def test_another_subclass_with_attributes + y = Y.new.tap {|y| y.val = 1} + y << "foo" << "bar" + y = Psych.load Psych.dump y + + assert_equal %w{foo bar}, y + assert_equal Y, y.class + assert_equal 1, y.val + end + def test_subclass yaml = Psych.dump X.new assert_match X.name, yaml diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index c7d5c60..77aefc6 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -9,6 +9,13 @@ module Psych attr_accessor :val end + def test_another_subclass_with_attributes + y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1} + assert_equal "foo", y + assert_equal Y, y.class + assert_equal 1, y.val + end + def test_backwards_with_syck x = Psych.load "--- !str:#{X.name} foo\n\n" assert_equal X, x.class |