diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-09-30 12:21:48 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-09-30 12:21:48 +0200 |
commit | 201d50164016bc519041af302f47d92f314abac5 (patch) | |
tree | 688544ac063d8a3825d96474055f5c11ad471972 /spec/ruby/core/exception | |
parent | ce986b41caa1f23b6d07914b8eca62fdff24e034 (diff) | |
download | ruby-201d50164016bc519041af302f47d92f314abac5.tar.gz |
Update to ruby/spec@9277d27
Diffstat (limited to 'spec/ruby/core/exception')
-rw-r--r-- | spec/ruby/core/exception/top_level_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/core/exception/top_level_spec.rb b/spec/ruby/core/exception/top_level_spec.rb index 96f957411e..97a91b0a58 100644 --- a/spec/ruby/core/exception/top_level_spec.rb +++ b/spec/ruby/core/exception/top_level_spec.rb @@ -5,6 +5,31 @@ describe "An Exception reaching the top level" do ruby_exe('raise "foo"', args: "2>&1").should.include?("in `<main>': foo (RuntimeError)") end + ruby_version_is "2.6" do + it "the Exception#cause is printed to STDERR with backtraces" do + code = <<-RUBY + def raise_cause + raise "the cause" + end + def raise_wrapped + raise "wrapped" + end + begin + raise_cause + rescue + raise_wrapped + end + RUBY + lines = ruby_exe(code, args: "2>&1").lines + lines.reject! { |l| l.include?('rescue in') } + lines.map! { |l| l.split(':')[2..-1].join(':').chomp } + lines.should == ["in `raise_wrapped': wrapped (RuntimeError)", + "in `<main>'", + "in `raise_cause': the cause (RuntimeError)", + "in `<main>'"] + end + end + describe "with a custom backtrace" do it "is printed on STDERR" do code = <<-RUBY |