1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* complex.c (nucomp_marshal_{dump,load}): preserve instance

variables.

	* rational.c (nurat_marshal_{dump,load}): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-09-16 10:21:23 +00:00
parent 73c8f02384
commit 7c3b57b5d1
5 changed files with 24 additions and 3 deletions

View file

@ -1,3 +1,10 @@
Tue Sep 16 19:18:40 2008 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (nucomp_marshal_{dump,load}): preserve instance
variables.
* rational.c (nurat_marshal_{dump,load}): ditto.
Tue Sep 16 18:28:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_gets_m): rdoc updated. limit counts in bytes.
@ -251,7 +258,7 @@ Sun Sep 14 13:48:03 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
Sun Sep 14 10:10:43 2008 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (f_{add,mul,sub}): omitted some shortcuts for preserve
* complex.c (f_{add,mul,sub}): omitted some shortcuts for preserving
signed zero anyway.
* complex.c (nucomp_negate): new.

View file

@ -937,8 +937,12 @@ nucomp_inspect(VALUE self)
static VALUE
nucomp_marshal_dump(VALUE self)
{
VALUE a;
get_dat1(self);
return rb_assoc_new(dat->real, dat->image);
a = rb_assoc_new(dat->real, dat->image);
rb_copy_generic_ivar(a, self);
return a;
}
static VALUE
@ -947,6 +951,7 @@ nucomp_marshal_load(VALUE self, VALUE a)
get_dat1(self);
dat->real = RARRAY_PTR(a)[0];
dat->image = RARRAY_PTR(a)[1];
rb_copy_generic_ivar(self, a);
return self;
}

View file

@ -1125,8 +1125,12 @@ nurat_inspect(VALUE self)
static VALUE
nurat_marshal_dump(VALUE self)
{
VALUE a;
get_dat1(self);
return rb_assoc_new(dat->num, dat->den);
a = rb_assoc_new(dat->num, dat->den);
rb_copy_generic_ivar(a, self);
return a;
}
static VALUE
@ -1135,6 +1139,7 @@ nurat_marshal_load(VALUE self, VALUE a)
get_dat1(self);
dat->num = RARRAY_PTR(a)[0];
dat->den = RARRAY_PTR(a)[1];
rb_copy_generic_ivar(self, a);
if (f_zero_p(dat->den))
rb_raise_zerodiv();

View file

@ -638,10 +638,12 @@ class Complex_Test < Test::Unit::TestCase
def test_marshal
c = Complex(1,2)
c.instance_eval{@ivar = 9}
s = Marshal.dump(c)
c2 = Marshal.load(s)
assert_equal(c, c2)
assert_equal(9, c2.instance_variable_get(:@ivar))
assert_instance_of(Complex, c2)
if defined?(Rational)

View file

@ -854,10 +854,12 @@ class Rational_Test < Test::Unit::TestCase
def test_marshal
c = Rational(1,2)
c.instance_eval{@ivar = 9}
s = Marshal.dump(c)
c2 = Marshal.load(s)
assert_equal(c, c2)
assert_equal(9, c2.instance_variable_get(:@ivar))
assert_instance_of(Rational, c2)
assert_raise(ZeroDivisionError){