From 3d0786a3a80932e99a63497597770fbb94401653 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 26 Jan 2013 13:39:15 +0000 Subject: marshal.c: marshal_dump instance varialbes * marshal.c (w_object): dump instance varialbes of the result of marshal_dump not the original object. [ruby-core:51163] [Bug #7627] * complex.c (nucomp_marshal_dump): need to copy instance variables. * rational.c (nurat_marshal_dump): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index bc5ee6295d..74f950b64c 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -517,4 +517,23 @@ class TestMarshal < Test::Unit::TestCase assert(!c.untrusted?, bug7325) end end + + class Bug7627 < Struct.new(:bar) + attr_accessor :foo + + def marshal_dump; 'dump'; end # fake dump data + def marshal_load(*); end # do nothing + end + + def test_marshal_dump_struct_ivar + bug7627 = '[ruby-core:51163]' + obj = Bug7627.new + obj.foo = '[Bug #7627]' + + dump = Marshal.dump(obj) + loaded = Marshal.load(dump) + + assert_equal(obj, loaded, bug7627) + assert_nil(loaded.foo, bug7627) + end end -- cgit v1.2.3