зеркало из https://github.com/github/ruby.git
error.c: negative uplevel
* error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d0afbff3b0
Коммит
fa2e4a2061
6
error.c
6
error.c
|
@ -342,7 +342,11 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc)
|
|||
uplevel = Qnil;
|
||||
}
|
||||
else if (!NIL_P(uplevel)) {
|
||||
uplevel = LONG2NUM((long)NUM2ULONG(uplevel) + 1);
|
||||
long lev = NUM2LONG(uplevel);
|
||||
if (lev < 0) {
|
||||
rb_raise(rb_eArgError, "negative level (%ld)", lev);
|
||||
}
|
||||
uplevel = LONG2NUM(lev + 1);
|
||||
uplevel = rb_vm_thread_backtrace_locations(1, &uplevel, GET_THREAD()->self);
|
||||
if (!NIL_P(uplevel)) {
|
||||
uplevel = rb_ary_entry(uplevel, 0);
|
||||
|
|
|
@ -1007,6 +1007,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
def test_kernel_warn_uplevel
|
||||
warning = capture_warning_warn {warn("test warning", uplevel: 0)}
|
||||
assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0])
|
||||
assert_raise(ArgumentError) {warn("test warning", uplevel: -1)}
|
||||
end
|
||||
|
||||
def test_warning_warn_invalid_argument
|
||||
|
|
Загрузка…
Ссылка в новой задаче