Skip to content

Fix FoundationTest build on macOS #2923

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

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Tests/Foundation/Tests/TestNSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct SwiftCustomNSError: Error, CustomNSError {
class TestNSError : XCTestCase {

static var allTests: [(String, (TestNSError) -> () throws -> Void)] {
return [
var tests: [(String, (TestNSError) -> () throws -> Void)] = [
("test_LocalizedError_errorDescription", test_LocalizedError_errorDescription),
("test_NSErrorAsError_localizedDescription", test_NSErrorAsError_localizedDescription),
("test_NSError_inDictionary", test_NSError_inDictionary),
Expand All @@ -23,12 +23,19 @@ class TestNSError : XCTestCase {
("test_CustomNSError_errorCodeRawInt", test_CustomNSError_errorCodeRawInt),
("test_CustomNSError_errorCodeRawUInt", test_CustomNSError_errorCodeRawUInt),
("test_errorConvenience", test_errorConvenience),
]

#if !canImport(ObjectiveC) || DARWIN_COMPATIBILITY_TESTS
tests.append(contentsOf: [
("test_ConvertErrorToNSError_domain", test_ConvertErrorToNSError_domain),
("test_ConvertErrorToNSError_errorCode", test_ConvertErrorToNSError_errorCode),
("test_ConvertErrorToNSError_errorCodeRawInt", test_ConvertErrorToNSError_errorCodeRawInt),
("test_ConvertErrorToNSError_errorCodeRawUInt", test_ConvertErrorToNSError_errorCodeRawUInt),
("test_ConvertErrorToNSError_errorCodeWithAssosiatedValue", test_ConvertErrorToNSError_errorCodeWithAssosiatedValue),
]
])
#endif

return tests
}

func test_LocalizedError_errorDescription() {
Expand Down Expand Up @@ -112,6 +119,8 @@ class TestNSError : XCTestCase {
}
}

#if !canImport(ObjectiveC) || DARWIN_COMPATIBILITY_TESTS

func test_ConvertErrorToNSError_domain() {
struct CustomSwiftError: Error {
}
Expand Down Expand Up @@ -164,6 +173,8 @@ class TestNSError : XCTestCase {
XCTAssertEqual((SwiftError.four as NSError).code, 4)
XCTAssertEqual((SwiftError.five("five") as NSError).code, 1)
}

#endif

}

Expand Down