-
Notifications
You must be signed in to change notification settings - Fork 263
Add regression test for XCTAssert* failure messages #39
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
Add regression test for XCTAssert* failure messages #39
Conversation
@@ -267,7 +267,7 @@ public func XCTAssertNil(@autoclosure expression: () -> Any?, @autoclosure _ mes | |||
if value == nil { | |||
return .Success | |||
} else { | |||
return .ExpectedFailure("\"\(value)\"") | |||
return .ExpectedFailure("\"\(value!)\"") |
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.
Could we reverse the conditional here, to avoid the !
? Exclamation points make me nervous. 😅
How about:
if let value = expression() {
return .ExpectedFailure("\"\(value)\"")
} else {
return .Success
}
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 had initially chosen to not reorder it that way because I liked the symmetry of the conditionals between the various assertion functions, but I have no problem flipping it.
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 just reverted it to the original ordering at @eschaton's request. AFAIK there is no clean way to avoid the force-unwrap when doing the nil
check first like this. Using guard
could allow keeping the ordering the same, but I feel it be a pretty bad abuse of the expected semantics of that keyword.
Is there an alternative I'm overlooking? @modocache
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.
Fine with me! I defer to him. 😄
c86ff1b
to
d02e208
Compare
Rebased and fixed up now. |
I strongly prefer the |
…ional This fix makes it match Darwin XCTest again.
d02e208
to
32d2a2b
Compare
Add regression test for XCTAssert* failure messages
This backfills tests for the behavior introduced in #22.
It also fixes a minor formatting regression introduced in e5cf2f4 in which the output of
XCTAssertNil
incorrectly prints the actual value as an optional.