зеркало из https://github.com/github/ruby.git
range.c: use rb_check_funcall
* range.c (rb_range_values): use rb_check_funcall instead of calling rb_respond_to then rb_funcall, and allow `begin` and `end` to be private as well as other internal conversions. [ruby-core:83541] [Bug #14048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
537a46c69a
Коммит
50a99a7679
8
range.c
8
range.c
|
@ -988,18 +988,10 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
|
|||
}
|
||||
else {
|
||||
VALUE x;
|
||||
#if 0
|
||||
/* TODO: fix spec/mspec/lib/mspec/mocks/mock.rb:Mock.verify_call */
|
||||
b = rb_check_funcall(range, id_beg, 0, 0);
|
||||
if (b == Qundef) return (int)Qfalse;
|
||||
e = rb_check_funcall(range, id_end, 0, 0);
|
||||
if (e == Qundef) return (int)Qfalse;
|
||||
#else
|
||||
if (!rb_respond_to(range, id_beg)) return (int)Qfalse;
|
||||
if (!rb_respond_to(range, id_end)) return (int)Qfalse;
|
||||
b = rb_funcall(range, id_beg, 0);
|
||||
e = rb_funcall(range, id_end, 0);
|
||||
#endif
|
||||
x = rb_check_funcall(range, rb_intern("exclude_end?"), 0, 0);
|
||||
if (x == Qundef) return (int)Qfalse;
|
||||
excl = RTEST(x);
|
||||
|
|
|
@ -393,6 +393,9 @@ class TestRange < Test::Unit::TestCase
|
|||
o.exclude_end = false
|
||||
assert_nil([0][o])
|
||||
assert_raise(RangeError) { [0][o] = 1 }
|
||||
class << o
|
||||
private :begin, :end
|
||||
end
|
||||
o.begin = 10
|
||||
o.end = 10
|
||||
assert_nil([0][o])
|
||||
|
|
Загрузка…
Ссылка в новой задаче