-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixed didPanic to now detect panic(nil). #793
Conversation
Nice! |
ACK good catch |
Hes my brother 💯 |
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.
Thanks for your effort. I've added some comments, would appreciate your feedback.
Could you also rebase this PR onto the latest master since it has been a while :)
|
||
return |
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.
Is this line not redundant/pointless now?
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.
I think it's required when returning named return values.
assert/assertions_test.go
Outdated
t.Error("didPanic should return true") | ||
const panicMsg = "Panic!" | ||
|
||
if funcDidPanic, msg := didPanic(func() { |
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.
Would it be a bit clearer if we separated these if
statements into two lines, assignment and if
check?
e.g.
funcDidPanic, msg := didPanic(func() {...})
if !funcDidPanic || msg != panicMsg {
...
}
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.
I think it's fine as it is. Reads as naturally as any other go code to me.
Any updates? :) |
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.
Thanks for your contribution :)
This PR needs to be updated and conflicts resolved before I can merge it. |
Previously, the function would not detect panic(nil) calls. In didPanic, removed the anonymous function call, instead, added named return values. Added extra test cases for the panic(nil) call.
dfbd2d6
Rebased, resolved conflicts. |
This is cheery-picked from stretchr/testify#793. Signed-off-by: tison <wander4096@gmail.com> Co-authored-by: RmbRT <steffen.rattay@gmail.com>
Previously, the function would not detect panic(nil) calls.
In didPanic, removed the anonymous function call, instead,
added named return values. Added extra test cases for the
panic(nil) call.
Closes #794.