зеркало из https://github.com/github/ruby.git
Use RTEST and add test for GH-6832
Technically we shouldn't see Qfalse now, but RTEST also compiles down to just one branch anyways. Pretty contrived issue, but easy to fix.
This commit is contained in:
Родитель
4b9d10b833
Коммит
5752d11f1f
2
struct.c
2
struct.c
|
@ -48,7 +48,7 @@ struct_ivar_get(VALUE c, ID id)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = rb_class_superclass(c);
|
c = rb_class_superclass(c);
|
||||||
if (c == 0 || c == rb_cStruct || c == rb_cData || c == Qnil)
|
if (c == rb_cStruct || c == rb_cData || !RTEST(c))
|
||||||
return Qnil;
|
return Qnil;
|
||||||
RUBY_ASSERT(RB_TYPE_P(c, T_CLASS));
|
RUBY_ASSERT(RB_TYPE_P(c, T_CLASS));
|
||||||
ivar = rb_attr_get(c, id);
|
ivar = rb_attr_get(c, id);
|
||||||
|
|
|
@ -92,6 +92,14 @@ class TestMarshal < Test::Unit::TestCase
|
||||||
TestMarshal.instance_eval { remove_const :StructInvalidMembers }
|
TestMarshal.instance_eval { remove_const :StructInvalidMembers }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_load_range_as_struct
|
||||||
|
assert_raise(TypeError, 'GH-6832') do
|
||||||
|
# Can be obtained with:
|
||||||
|
# $ ruby -e 'Range = Struct.new(:a, :b, :c); p Marshal.dump(Range.new(nil, nil, nil))'
|
||||||
|
Marshal.load("\x04\bS:\nRange\b:\x06a0:\x06b0:\x06c0")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class C
|
class C
|
||||||
def initialize(str)
|
def initialize(str)
|
||||||
@str = str
|
@str = str
|
||||||
|
|
Загрузка…
Ссылка в новой задаче