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

* range.c (range_dumper): make uninitialized range dumpable.

(range_loader): make uninitialized range loadable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-09-10 06:50:22 +00:00
parent 4261abb230
commit 068d11ef96
3 changed files with 13 additions and 3 deletions

View file

@ -1,7 +1,10 @@
Mon Sep 10 15:22:24 2007 Tanaka Akira <akr@fsij.org>
Mon Sep 10 15:48:31 2007 Tanaka Akira <akr@fsij.org>
* range.c: represent initialized state using EXCL instead of FL_USER3.
* range.c (range_dumper): make uninitialized range dumpable.
(range_loader): make uninitialized range loadable.
Mon Sep 10 13:44:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_cycle): avoid infinite loop for empty array.

View file

@ -758,7 +758,7 @@ range_dumper(VALUE range)
v = (VALUE)m;
rb_ivar_set(v, id_excl, EXCL(range) ? Qtrue : Qfalse);
rb_ivar_set(v, id_excl, RANGE_EXCL(range));
rb_ivar_set(v, id_beg, RANGE_BEG(range));
rb_ivar_set(v, id_end, RANGE_END(range));
return v;
@ -773,7 +773,7 @@ range_loader(VALUE range, VALUE obj)
RSTRUCT(range)->as.ary[0] = rb_ivar_get(obj, id_beg);
RSTRUCT(range)->as.ary[1] = rb_ivar_get(obj, id_end);
SET_EXCL(range, RTEST(rb_ivar_get(obj, id_excl)));
RSTRUCT(range)->as.ary[2] = rb_ivar_get(obj, id_excl);
return range;
}

View file

@ -64,4 +64,11 @@ class TestRange < Test::Unit::TestCase
r = eval("1..2")
assert_raise(NameError) { r.instance_eval { initialize 3, 4 } }
end
def test_uninitialized_range
r = Range.allocate
s = Marshal.dump(r)
r = Marshal.load(s)
assert_nothing_raised { r.instance_eval { initialize 5, 6} }
end
end