diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-08 14:02:01 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-08 14:02:01 -0800 |
commit | 8f84ad0fc711a82a1040def861cb121e8985fd4c (patch) | |
tree | 6409e61de6d8fe5057cead7e9c76ec59b629c264 /test | |
parent | 1109112f5785f6d55a74fed8f04a174e52293af5 (diff) | |
download | psych-8f84ad0fc711a82a1040def861cb121e8985fd4c.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
fixes #43
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_hash.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 264a471..8d7ba1b 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) |