зеркало из https://github.com/github/ruby.git
* struct.c (rb_struct_set): return assigned value from setter method
rather than struct object. [Bug #9353] [ruby-core:59509] * test/ruby/test_struct.rb (test_setter_method_returns_value): add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
54f6b3fe82
Коммит
306c154c2d
|
@ -1,3 +1,10 @@
|
|||
Sat Jan 4 22:44:00 2014 Charlie Somerville <charliesome@ruby-lang.org>
|
||||
|
||||
* struct.c (rb_struct_set): return assigned value from setter method
|
||||
rather than struct object. [Bug #9353] [ruby-core:59509]
|
||||
|
||||
* test/ruby/test_struct.rb (test_setter_method_returns_value): add test
|
||||
|
||||
Sat Jan 4 21:44:31 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* test/ruby/test_gc.rb (TestGc#test_latest_gc_info): use
|
||||
|
|
3
struct.c
3
struct.c
|
@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val)
|
|||
for (i=0; i<len; i++) {
|
||||
slot = RARRAY_AREF(members, i);
|
||||
if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
|
||||
return RSTRUCT_SET(obj, i, val);
|
||||
RSTRUCT_SET(obj, i, val);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",
|
||||
|
|
|
@ -298,6 +298,12 @@ module TestStruct
|
|||
assert_same(x, o.b!)
|
||||
end
|
||||
|
||||
def test_setter_method_returns_value
|
||||
klass = @Struct.new(:a)
|
||||
x = klass.new
|
||||
assert_equal "[Bug #9353]", x.send(:a=, "[Bug #9353]")
|
||||
end
|
||||
|
||||
class TopStruct < Test::Unit::TestCase
|
||||
include TestStruct
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче