aboutsummaryrefslogtreecommitdiffstats
path: root/test/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-08 22:00:54 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-08 22:00:54 +0000
commit8c08c8298a03a01629a478b74abfd57d7f35cb05 (patch)
treebe53d22fe5df98d9a4405d61a496d1ef0d9d8c0c /test/psych
parent2b2f9b75febc5d7a9b1384f84ee161a16af9f83d (diff)
downloadruby-8c08c8298a03a01629a478b74abfd57d7f35cb05.tar.gz
* ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivars
* ext/psych/lib/psych/visitors/yaml_tree.rb: dump hashes with ivars. Fixes github.com/psych/issues/43 * test/psych/test_hash.rb: test for change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_hash.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 264a4719e2..8d7ba1b1e0 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -10,6 +10,22 @@ module Psych
@hash = { :a => 'b' }
end
+ def test_hash_with_ivars
+ @hash.instance_variable_set :@foo, 'bar'
+ dup = Psych.load Psych.dump @hash
+ assert_equal 'bar', dup.instance_variable_get(:@foo)
+ end
+
+ def test_hash_subclass_with_ivars
+ x = X.new
+ x[:a] = 'b'
+ x.instance_variable_set :@foo, 'bar'
+ dup = Psych.load Psych.dump x
+ assert_cycle x
+ assert_equal 'bar', dup.instance_variable_get(:@foo)
+ assert_equal X, dup.class
+ end
+
def test_load_with_class_syck_compatibility
hash = Psych.load "--- !ruby/object:Hash\n:user_id: 7\n:username: Lucas\n"
assert_equal({ user_id: 7, username: 'Lucas'}, hash)