Bug #7575 » patch.diff
struct.c | ||
---|---|---|
len = RARRAY_LEN(members);
|
||
for (i=0; i< len; i++) {
|
||
ID id = SYM2ID(ptr_members[i]);
|
||
if (rb_is_local_id(id) || rb_is_const_id(id)) {
|
||
if (i < N_REF_FUNC) {
|
||
rb_define_method_id(nstr, id, ref_func[i], 0);
|
||
}
|
||
else {
|
||
rb_define_method_id(nstr, id, rb_struct_ref, 0);
|
||
}
|
||
rb_define_method_id(nstr, rb_id_attrset(id), rb_struct_set, 1);
|
||
if (i < N_REF_FUNC) {
|
||
rb_define_method_id(nstr, id, ref_func[i], 0);
|
||
}
|
||
else {
|
||
rb_define_method_id(nstr, id, rb_struct_ref, 0);
|
||
}
|
||
rb_define_method_id(nstr, rb_id_attrset(id), rb_struct_set, 1);
|
||
}
|
||
return nstr;
|
test/ruby/test_struct.rb | ||
---|---|---|
assert_equal("#<struct Struct::R\u{e9}sum\u{e9} r\u{e9}sum\u{e9}=42>", a.inspect, '[ruby-core:24849]')
|
||
end
|
||
def test_junk
|
||
struct_test = Struct.new("Foo", "a\000")
|
||
o = struct_test.new(1)
|
||
assert_equal(1, o.send("a\000"))
|
||
Struct.instance_eval { remove_const(:Foo) }
|
||
end
|
||
def test_comparison_when_recursive
|
||
klass1 = Struct.new(:a, :b, :c)
|
||