Skip to content

Commit 215cc0d

Browse files
committed
Add spec to test $! is set while rescuing another exception.
1 parent 72e93c5 commit 215cc0d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

spec/ruby/optional/capi/exception_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,25 @@
3737
-> { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42')
3838
end
3939

40-
it "sets $! to the raised exception" do
40+
it "sets $! to the raised exception when not rescuing from an another exception" do
4141
runtime_error = RuntimeError.new '42'
4242
runtime_error.set_backtrace []
4343
begin
44-
@s. rb_exc_raise(runtime_error)
44+
@s.rb_exc_raise(runtime_error)
45+
rescue
46+
$!.should == runtime_error
47+
end
48+
end
49+
50+
it "sets $! to the raised exception when $! when rescuing from an another exception" do
51+
runtime_error = RuntimeError.new '42'
52+
runtime_error.set_backtrace []
53+
begin
54+
begin
55+
raise StandardError
56+
rescue
57+
@s.rb_exc_raise(runtime_error)
58+
end
4559
rescue
4660
$!.should == runtime_error
4761
end

0 commit comments

Comments
 (0)