summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
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)