Skip to content

Commit d9b3cfd

Browse files
committed
Specs for type validation of writes to $@
1 parent 111cee4 commit d9b3cfd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

language/predefined_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,30 @@ def foo
621621
end
622622
end
623623

624+
ruby_version_is ""..."3.4" do
625+
it "can only be assigned an array of String" do
626+
begin
627+
raise
628+
rescue
629+
-> {
630+
$@ = 123
631+
}.should raise_error(TypeError, "backtrace must be Array of String")
632+
end
633+
end
634+
end
635+
636+
ruby_version_is "3.4" do
637+
it "can only be assigned an array of String or an Array of Thread::Backtrace::Location" do
638+
begin
639+
raise
640+
rescue
641+
-> {
642+
$@ = 123
643+
}.should raise_error(TypeError, "backtrace must be an Array of String or an Array of Thread::Backtrace::Location")
644+
end
645+
end
646+
end
647+
624648
it "cannot be assigned when there is no a rescued exception" do
625649
-> {
626650
$@ = []

0 commit comments

Comments
 (0)