diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-07-15 18:46:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-07-15 21:39:20 +0900 |
commit | 579645d9f870fa4116dcd3200bbbb6e2c0b7f400 (patch) | |
tree | 8b4ec513e37f47ec76f8eada1f45d91980a29650 /test/ruby/test_exception.rb | |
parent | 79d06483a8ac98a87e5c32d3a34823382a72a0da (diff) |
Fixed infinite loop at error in printing cause [Bug #17033]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3320
Diffstat (limited to 'test/ruby/test_exception.rb')
-rw-r--r-- | test/ruby/test_exception.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 9529fc8013..4decddc273 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -814,6 +814,26 @@ end.join } end + def test_cause_exception_in_cause_message + assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}") do |outs, errs, status| + begin; + exc = Class.new(StandardError) do + def initialize(obj, cnt) + super(obj) + @errcnt = cnt + end + def to_s + return super if @errcnt <= 0 + @errcnt -= 1 + raise "xxx" + end + end.new("ok", 10) + raise "[Bug #17033]", cause: exc + end; + assert_equal(1, errs.count {|m| m.include?("[Bug #17033]")}, proc {errs.pretty_inspect}) + end + end + def test_anonymous_message assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/) end |