Skip to content

Commit b16a93e

Browse files
committed
Specs for type validation of writes to $@
Use the shared specs for Exception#set_backtrace
1 parent 70c78f0 commit b16a93e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

language/predefined_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require_relative '../spec_helper'
2+
require_relative '../core/exception/shared/set_backtrace'
23
require 'stringio'
34

45
# The following tables are excerpted from Programming Ruby: The Pragmatic Programmer's Guide'
@@ -621,6 +622,17 @@ def foo
621622
end
622623
end
623624

625+
it_behaves_like :exception_set_backtrace, ->(*backtrace) {
626+
exception = nil
627+
begin
628+
raise
629+
rescue
630+
$@ = backtrace.first unless backtrace.empty?
631+
exception = $!
632+
end
633+
exception
634+
}
635+
624636
it "cannot be assigned when there is no a rescued exception" do
625637
-> {
626638
$@ = []

0 commit comments

Comments
 (0)