Skip to content

Conversation

@egorzhdan
Copy link
Contributor

These functions are available in Xcode 12.5, but aren't available on Linux/Windows.
This change adds the implementations for them.

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

// CHECK: test.swift:[[@LINE+3]]: error: FailureMessagesTestCase.testAssertNotIdentical : XCTAssertNotIdentical failed: \("nil"\) is identical to \("nil"\) - message
// CHECK: Test Case 'FailureMessagesTestCase.testAssertNotIdentical' failed \(\d+\.\d+ seconds\)
func testAssertNotIdentical() {
XCTAssertNotIdentical(nil, nil, "message", file: "test.swift")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change! I think we can land it soon

My only request is that you add a few more assertions to these two tests, in particular success cases which validate that both XCTAssertIdentical and XCTAssertNotIdentical succeed when passed identical or not identical values, respectively. Currently, the tests only validate failure scenarios, but we should be sure to have tests covering when they pass as well. Personally, I'm fine just adding those inside the existing two test method bodies, to keep things simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a good point. I added a few succeeding assertions to the test.

@egorzhdan egorzhdan force-pushed the XCTAssertIdentical branch from 3b83664 to 507bb91 Compare August 4, 2021 18:53
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

// CHECK: Test Case 'FailureMessagesTestCase.testAssertIdentical' failed \(\d+\.\d+ seconds\)
func testAssertIdentical() {
let object = XCTestExpectation()
XCTAssertIdentical(object as AnyObject, object as AnyObject)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually necessary to cast these using as AnyObject ? I would expect it to work without the casts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this specific assertion the cast wasn't needed indeed, I removed it.
All the other assertions require a cast to avoid a compiler error (type of expression is ambiguous without more context).

These functions are available in Xcode 12.5, but aren't available on Linux/Windows. This change adds the implementations for them.
@egorzhdan egorzhdan force-pushed the XCTAssertIdentical branch from 507bb91 to cdda9d7 Compare August 4, 2021 19:11
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@briancroom
Copy link
Contributor

Looks great. Thank you!

@briancroom briancroom merged commit 4e35114 into swiftlang:main Aug 4, 2021
stmontgomery pushed a commit to stmontgomery/swift-corelibs-xctest that referenced this pull request Aug 5, 2021
Implement XCTAssertIdentical & XCTAssertNotIdentical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants