Skip to content
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

[SR-1417] XCTAssertEqual confusingly mentions Optionals on failure #388

Closed
nsalmoria opened this issue May 5, 2016 · 7 comments
Closed

Comments

@nsalmoria
Copy link
Contributor

Previous ID SR-1417
Radar None
Original Reporter @nsalmoria
Type Bug
Status Resolved
Resolution Done
Environment

Swift Development Snapshot 2016-05-03 (a), Xcode 7.3.1

Additional Detail from JIRA
Votes 0
Component/s XCTest
Labels Bug, SDKOverlay, StarterBug, XCTest
Assignee @nsalmoria
Priority Medium

md5: 2a54820de78ceab6bbb23475c5f7f798

Issue Description:

When using XCTAssertEqual() to test that two values are equal, the error message in case of failure always assumes that the two values are Optional.

For example, this line:

XCTAssertEqual(1, 2)

prints:

XCTAssertEqual failed: ("Optional(1)") is not equal to ("Optional(2)")

This is confusing since the values passed to XCTAsserEqual are not Optionals, and adds visual noise to the error report.

It would be expected that the error should simply be

XCTAssertEqual failed: ("1") is not equal to ("2")

@modocache
Copy link
Mannequin

modocache mannequin commented May 12, 2016

This could definitely be improved, thanks @nsalmoria! Do you happen to know if this is a recent change in behavior, or has swift-corelibs-xctest always acted in this way?

@nsalmoria
Copy link
Contributor Author

I'm embarrassed to say that I only recently started using that function, so I don't know if it has always been like that or not.

@modocache
Copy link
Mannequin

modocache mannequin commented May 12, 2016

No need to be embarrassed![]( I only ask because it would be easier to suggest a fix if it were a recent regression -- we could pinpoint the commit that introduced this. In any case, thanks for the report)! I'll try and take a look in the next week or so. Of course anyone should feel welcome to grab this task before then. 🙂

@nsalmoria
Copy link
Contributor Author

I'll have a go at it. It's a StarterBug after all!

@nsalmoria
Copy link
Contributor Author

PR: #110

@nsalmoria
Copy link
Contributor Author

Swift PR: apple/swift#2551

@nsalmoria
Copy link
Contributor Author

Fixed by the merge of apple/swift#2788 and apple/swift-corelibs-xctest#123

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant