mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
gc.c: private call
* gc.c (should_be_callable): allow private call since rb_eval_cmd calls even private methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a330ba230
commit
3fdff0501a
3 changed files with 27 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Nov 10 00:36:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* gc.c (should_be_callable): allow private call since rb_eval_cmd
|
||||||
|
calls even private methods.
|
||||||
|
|
||||||
Sun Nov 10 00:33:17 2013 Zachary Scott <e@zzak.io>
|
Sun Nov 10 00:33:17 2013 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada
|
* lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada
|
||||||
|
|
2
gc.c
2
gc.c
|
@ -1866,7 +1866,7 @@ rb_undefine_final(VALUE obj)
|
||||||
static void
|
static void
|
||||||
should_be_callable(VALUE block)
|
should_be_callable(VALUE block)
|
||||||
{
|
{
|
||||||
if (!rb_respond_to(block, rb_intern("call"))) {
|
if (!rb_obj_respond_to(block, rb_intern("call"), TRUE)) {
|
||||||
rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
|
rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
|
||||||
rb_obj_classname(block));
|
rb_obj_classname(block));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,27 @@ End
|
||||||
!b
|
!b
|
||||||
END
|
END
|
||||||
assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
|
assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
|
||||||
|
fin = Struct.new(:garbage).new
|
||||||
|
class << fin
|
||||||
|
alias call garbage=
|
||||||
|
end
|
||||||
|
assertion = proc do
|
||||||
|
fin.garbage = nil
|
||||||
|
assert_nothing_raised(ArgumentError) {
|
||||||
|
EnvUtil.under_gc_stress do
|
||||||
|
3.times do
|
||||||
|
ObjectSpace.define_finalizer([], fin)
|
||||||
|
end
|
||||||
|
GC.start
|
||||||
|
end
|
||||||
|
}
|
||||||
|
assert_not_nil(fin.garbage)
|
||||||
|
end
|
||||||
|
assertion.call
|
||||||
|
class << fin
|
||||||
|
private :call
|
||||||
|
end
|
||||||
|
assertion.call
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each_object
|
def test_each_object
|
||||||
|
|
Loading…
Add table
Reference in a new issue