diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-05-28 22:41:48 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-05-28 22:41:48 +0200 |
commit | a66bc2c01194a9c017c874a30db5b3b6bd95e966 (patch) | |
tree | 598d6375b44fd86f90c3477c73086f6fcf08d76c /spec/ruby/core/exception | |
parent | d070523e7be4b95914adeef9a10401fba7718c5a (diff) |
Update to ruby/spec@9a501a8
Diffstat (limited to 'spec/ruby/core/exception')
-rw-r--r-- | spec/ruby/core/exception/backtrace_spec.rb | 15 | ||||
-rw-r--r-- | spec/ruby/core/exception/cause_spec.rb | 12 |
2 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/core/exception/backtrace_spec.rb b/spec/ruby/core/exception/backtrace_spec.rb index 70c75bda1e..5e140f8d9b 100644 --- a/spec/ruby/core/exception/backtrace_spec.rb +++ b/spec/ruby/core/exception/backtrace_spec.rb @@ -65,4 +65,19 @@ describe "Exception#backtrace" do e.backtrace[0].should == "backtrace first" end end + + it "returns the same array after duping" do + begin + raise + rescue RuntimeError => err + bt = err.backtrace + err.dup.backtrace.should equal(bt) + + new_bt = ['hi'] + err.set_backtrace new_bt + + err.backtrace.should == new_bt + err.dup.backtrace.should equal(new_bt) + end + end end diff --git a/spec/ruby/core/exception/cause_spec.rb b/spec/ruby/core/exception/cause_spec.rb index 007df41366..cf4aaeb188 100644 --- a/spec/ruby/core/exception/cause_spec.rb +++ b/spec/ruby/core/exception/cause_spec.rb @@ -41,4 +41,16 @@ describe "Exception#cause" do e.cause.should equal(cause) } end + + it "is not set to the exception itself when it is re-raised" do + -> { + begin + raise RuntimeError + rescue RuntimeError => e + raise e + end + }.should raise_error(RuntimeError) { |e| + e.cause.should == nil + } + end end |