diff options
author | nagachika <nagachika@ruby-lang.org> | 2020-07-23 12:13:30 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2020-07-23 12:13:30 +0900 |
commit | 27fa1c61b78c1685ccf9ac203a95cfa9041d618f (patch) | |
tree | 88ce359e50f4789a7479753ea91ec1adbebf5b2b /test/ruby | |
parent | 4be9bf1f67b997fc519625d56a93b8a68a70d124 (diff) |
merge revision(s) 579645d9f870fa4116dcd3200bbbb6e2c0b7f400: [Backport #17033]
Fixed infinite loop at error in printing cause [Bug #17033]
Diffstat (limited to 'test/ruby')
-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 79ac11ab26..69bf7ebf0e 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -824,6 +824,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 |