From 905189b2e3a7d746af91cdea254ed041a5fc111f Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 2 Jul 2018 00:31:27 +0000 Subject: merge revision(s) 61525,61527,63062,63650: [Backport #14846] error.c: negative uplevel * error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262] error.c: limit depth * error.c (rb_warn_m): limit backtrace depth to reduce objects to be created but not used. error.c: prepend "warning: " always * error.c (rb_warn_m): prepend the string "warning: " if uplevel keyword is given, even if caller file and line information are not available. Fix condition in Kernel#warn when using uplevel * It causes SEGV on `warn("foo", uplevel: 100)`. * Found in a ruby/spec added by @andrykonchin in https://github.com/ruby/spec/pull/605 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_exception.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 62d393a725..8d11e3bafc 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1007,6 +1007,8 @@ $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)} + assert_in_out_err(["-e", "warn 'ok', uplevel: 1"], '', [], /warning:/) end def test_warning_warn_invalid_argument -- cgit v1.2.3