-
Notifications
You must be signed in to change notification settings - Fork 229
[Kernel] Add tests for Exiting and Exception functions #2684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Kernel] Add tests for Exiting and Exception functions #2684
Conversation
2789ea5 to
49593f8
Compare
ksss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking for a value like SystemExit rather than a type seems to be testing behavior, not the type.
The idea is to make sure that the exception that was thrown was one we expected from |
| def self?.fail: () -> bot | ||
| | (string message, ?cause: Exception?) -> bot | ||
| | (_Exception exception, ?_ToS? message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot | ||
| | (_Exception exception, ?string | _ToS message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why we need this fix on the argument type?
It looks like _ToS message would be fine technically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#to_str is used if #to_s is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other way around—it tries to_str first:
class Foo
def to_s = "to_s!"
def to_str = "to_str!"
end
fail RuntimeError, Foo.new #=> -e:6:in '<main>': to_str! (RuntimeError)49593f8 to
052b14f
Compare
This PR adds tests for
Kernel.{abort,exit,exit!,at_exit}andKernel.{throw,catch,raise,fail}, as well as slightly tweaking thefailsignature.Additionally, it adds in the
assert_send_type_errormethod (which is just a direct copy ofassert_send_type, but accepts a type as the second argument)