From 1cc1ea378a0912bfcbe55399369da47a724427aa Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Dec 2009 06:35:07 +0000 Subject: * marshal.c (w_object): dump instance variables when using marshal_dump. [ruby-core:24211] * variable.c (rb_ivar_count): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 0b37b7ab17..71936ec147 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -310,4 +310,24 @@ class TestMarshal < Test::Unit::TestCase Marshal.dump(Object.new, w) assert_not_empty(w, bug2390) end + + class C5 + def marshal_dump + "foo" + end + def marshal_load(foo) + @foo = foo + end + def initialize(x) + @x = x + end + end + def test_marshal_dump + bug1744 = '[ruby-core:24211]' + c = C5.new("bar") + s = Marshal.dump(c) + d = Marshal.load(s) + assert_equal("foo", d.instance_variable_get(:@foo), bug1744) + assert_equal("bar", d.instance_variable_get(:@x), bug1744) + end end -- cgit v1.2.3