Skip to content

Commit c975330

Browse files
committed
[SE-0066] Adapt to new function type syntax
SE-0066, which standardizes the function type argument syntax to require parentheses, was landed in Swift master as of swiftlang/swift@3d2b5bc. The change results in warnings when compiling XCTest and its test suite. Enclose the function types in parentheses to fix the warning.
1 parent 4a25dfc commit c975330

File tree

20 files changed

+28
-29
lines changed

20 files changed

+28
-29
lines changed

Documentation/Linux.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ When running on the Objective-C runtime, XCTest is able to find all of your test
44

55
```swift
66
class TestNSURL : XCTestCase {
7-
static var allTests : [(String, TestNSURL -> () throws -> Void)] {
7+
static var allTests : [(String, (TestNSURL) -> () throws -> Void)] {
88
return [
99
("test_URLStrings", test_URLStrings),
1010
("test_fileURLWithPath_relativeToURL", test_fileURLWithPath_relativeToURL),

Sources/XCTest/XCAbstractTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ public class XCTest {
6868
// FIXME: This initializer is required due to a Swift compiler bug on Linux.
6969
// It should be removed once the bug is fixed.
7070
public init() {}
71-
}
71+
}

Sources/XCTest/XCTestCase.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/// This type is intended to be produced by the `testCase` helper function.
2323
/// - seealso: `testCase`
2424
/// - seealso: `XCTMain`
25-
public typealias XCTestCaseEntry = (testCaseClass: XCTestCase.Type, allTests: [(String, XCTestCase throws -> Void)])
25+
public typealias XCTestCaseEntry = (testCaseClass: XCTestCase.Type, allTests: [(String, (XCTestCase) throws -> Void)])
2626

2727
// A global pointer to the currently running test case. This is required in
2828
// order for XCTAssert functions to report failures.
@@ -33,7 +33,7 @@ internal var XCTCurrentTestCase: XCTestCase?
3333
/// methods containing the tests to run.
3434
/// - seealso: `XCTMain`
3535
public class XCTestCase: XCTest {
36-
private let testClosure: XCTestCase throws -> Void
36+
private let testClosure: (XCTestCase) throws -> Void
3737

3838
/// The name of the test case, consisting of its class name and the method
3939
/// name it will run.
@@ -81,7 +81,7 @@ public class XCTestCase: XCTest {
8181
/// - Note: Like the designated initializer for Apple XCTest's XCTestCase,
8282
/// `-[XCTestCase initWithInvocation:]`, it's rare for anyone outside of
8383
/// XCTest itself to call this initializer.
84-
public required init(name: String, testClosure: XCTestCase throws -> Void) {
84+
public required init(name: String, testClosure: (XCTestCase) throws -> Void) {
8585
_name = "\(self.dynamicType).\(name)"
8686
self.testClosure = testClosure
8787
}
@@ -142,7 +142,7 @@ public class XCTestCase: XCTest {
142142
/// Wrapper function allowing an array of static test case methods to fit
143143
/// the signature required by `XCTMain`
144144
/// - seealso: `XCTMain`
145-
public func testCase<T: XCTestCase>(_ allTests: [(String, T -> () throws -> Void)]) -> XCTestCaseEntry {
145+
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () throws -> Void)]) -> XCTestCaseEntry {
146146
let tests: [(String, XCTestCase throws -> Void)] = allTests.map { ($0.0, test($0.1)) }
147147
return (T.self, tests)
148148
}
@@ -158,7 +158,6 @@ private func test<T: XCTestCase>(_ testFunc: T -> () throws -> Void) -> XCTestCa
158158
}
159159

160160
extension XCTestCase {
161-
162161
public var continueAfterFailure: Bool {
163162
get {
164163
return true

Sources/XCTest/XCTestMain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// Example usage:
2727
///
2828
/// class TestFoo: XCTestCase {
29-
/// static var allTests : [(String, TestFoo -> () throws -> Void)] {
29+
/// static var allTests : [(String, (TestFoo) -> () throws -> Void)] {
3030
/// return [
3131
/// ("test_foo", test_foo),
3232
/// ("test_bar", test_bar),

Tests/Functional/Asynchronous/Expectations/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ExpectationsTestCase: XCTestCase {
7979
waitForExpectations(withTimeout: -1.0)
8080
}
8181

82-
static var allTests: [(String, ExpectationsTestCase -> () throws -> Void)] {
82+
static var allTests: [(String, (ExpectationsTestCase) -> () throws -> Void)] {
8383
return [
8484
("test_waitingForAnUnfulfilledExpectation_fails", test_waitingForAnUnfulfilledExpectation_fails),
8585
("test_waitingForUnfulfilledExpectations_outputsAllExpectations_andFails", test_waitingForUnfulfilledExpectations_outputsAllExpectations_andFails),

Tests/Functional/Asynchronous/Handler/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class HandlerTestCase: XCTestCase {
4545
XCTAssertTrue(handlerWasCalled)
4646
}
4747

48-
static var allTests: [(String, HandlerTestCase -> () throws -> Void)] {
48+
static var allTests: [(String, (HandlerTestCase) -> () throws -> Void)] {
4949
return [
5050
("test_whenExpectationsAreNotFulfilled_handlerCalled_andFails", test_whenExpectationsAreNotFulfilled_handlerCalled_andFails),
5151
("test_whenExpectationsAreFulfilled_handlerCalled_andPasses", test_whenExpectationsAreFulfilled_handlerCalled_andPasses),

Tests/Functional/Asynchronous/Misuse/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MisuseTestCase: XCTestCase {
4949
self.waitForExpectations(withTimeout: 0.1)
5050
}
5151

52-
static var allTests: [(String, MisuseTestCase -> () throws -> Void)] {
52+
static var allTests: [(String, (MisuseTestCase) -> () throws -> Void)] {
5353
return [
5454
("test_whenExpectationsAreMade_butNotWaitedFor_fails", test_whenExpectationsAreMade_butNotWaitedFor_fails),
5555
("test_whenNoExpectationsAreMade_butTheyAreWaitedFor_fails", test_whenNoExpectationsAreMade_butTheyAreWaitedFor_fails),

Tests/Functional/Asynchronous/Notifications/Expectations/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class NotificationExpectationsTestCase: XCTestCase {
6666
waitForExpectations(withTimeout: 0.1)
6767
}
6868

69-
static var allTests: [(String, NotificationExpectationsTestCase -> () throws -> Void)] {
69+
static var allTests: [(String, (NotificationExpectationsTestCase) -> () throws -> Void)] {
7070
return [
7171
("test_observeNotificationWithName_passes", test_observeNotificationWithName_passes),
7272
("test_observeNotificationWithNameAndObject_passes", test_observeNotificationWithNameAndObject_passes),

Tests/Functional/Asynchronous/Notifications/Handler/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class NotificationHandlerTestCase: XCTestCase {
5050
NSNotificationCenter.defaultCenter().postNotificationName("note", object: nil)
5151
}
5252

53-
static var allTests: [(String, NotificationHandlerTestCase -> () throws -> Void)] {
53+
static var allTests: [(String, (NotificationHandlerTestCase) -> () throws -> Void)] {
5454
return [
5555
("test_notificationNameIsObserved_handlerReturnsFalse_andFails", test_notificationNameIsObserved_handlerReturnsFalse_andFails),
5656
("test_notificationNameIsObserved_handlerReturnsTrue_andPasses", test_notificationNameIsObserved_handlerReturnsTrue_andPasses),

Tests/Functional/Asynchronous/Predicates/Expectations/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PredicateExpectationsTestCase: XCTestCase {
6363
waitForExpectations(withTimeout: 0.1)
6464
}
6565

66-
static var allTests: [(String, PredicateExpectationsTestCase -> () throws -> Void)] {
66+
static var allTests: [(String, (PredicateExpectationsTestCase) -> () throws -> Void)] {
6767
return [
6868
("test_immediatelyTruePredicateAndObject_passes", test_immediatelyTruePredicateAndObject_passes),
6969
("test_immediatelyFalsePredicateAndObject_fails", test_immediatelyFalsePredicateAndObject_fails),

Tests/Functional/Asynchronous/Predicates/Handler/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PredicateHandlerTestCase: XCTestCase {
5555
waitForExpectations(withTimeout: 0.1, handler: nil)
5656
}
5757

58-
static var allTests: [(String, PredicateHandlerTestCase -> () throws -> Void)] {
58+
static var allTests: [(String, (PredicateHandlerTestCase) -> () throws -> Void)] {
5959
return [
6060
("test_predicateIsTrue_handlerReturnsTrue_passes", test_predicateIsTrue_handlerReturnsTrue_passes),
6161
("test_predicateIsTrue_handlerReturnsFalse_fails", test_predicateIsTrue_handlerReturnsFalse_fails),

Tests/Functional/ErrorHandling/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// CHECK: Test Suite 'ErrorHandling' started at \d+:\d+:\d+\.\d+
1515
class ErrorHandling: XCTestCase {
16-
static var allTests: [(String, ErrorHandling -> () throws -> Void)] {
16+
static var allTests: [(String, (ErrorHandling) -> () throws -> Void)] {
1717
return [
1818
// Tests for XCTAssertThrowsError
1919
("test_shouldButDoesNotThrowErrorInAssertion", test_shouldButDoesNotThrowErrorInAssertion),
@@ -112,4 +112,4 @@ XCTMain([testCase(ErrorHandling.allTests)])
112112
// CHECK: Test Suite '.*\.xctest' failed at \d+:\d+:\d+\.\d+
113113
// CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
114114
// CHECK: Test Suite 'All tests' failed at \d+:\d+:\d+\.\d+
115-
// CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
115+
// CHECK: \t Executed 6 tests, with 4 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds

Tests/Functional/FailingTestSuite/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// CHECK: Test Suite 'PassingTestCase' started at \d+:\d+:\d+\.\d+
1515
class PassingTestCase: XCTestCase {
16-
static var allTests: [(String, PassingTestCase -> () throws -> Void)] {
16+
static var allTests: [(String, (PassingTestCase) -> () throws -> Void)] {
1717
return [
1818
("test_passes", test_passes),
1919
]
@@ -30,7 +30,7 @@ class PassingTestCase: XCTestCase {
3030

3131
// CHECK: Test Suite 'FailingTestCase' started at \d+:\d+:\d+\.\d+
3232
class FailingTestCase: XCTestCase {
33-
static var allTests: [(String, FailingTestCase -> () throws -> Void)] {
33+
static var allTests: [(String, (FailingTestCase) -> () throws -> Void)] {
3434
return [
3535
("test_passes", test_passes),
3636
("test_fails", test_fails),

Tests/Functional/FailureMessagesTestCase/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// CHECK: Test Suite 'FailureMessagesTestCase' started at \d+:\d+:\d+\.\d+
1717
class FailureMessagesTestCase: XCTestCase {
18-
static var allTests: [(String, FailureMessagesTestCase -> () throws -> Void)] {
18+
static var allTests: [(String, (FailureMessagesTestCase) -> () throws -> Void)] {
1919
return [
2020
("testAssert", testAssert),
2121
("testAssertEqualOptionals", testAssertEqualOptionals),

Tests/Functional/NegativeAccuracyTestCase/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// CHECK: Test Suite 'NegativeAccuracyTestCase' started at \d+:\d+:\d+\.\d+
1717
class NegativeAccuracyTestCase: XCTestCase {
18-
static var allTests: [(String, NegativeAccuracyTestCase -> () throws -> Void)] {
18+
static var allTests: [(String, (NegativeAccuracyTestCase) -> () throws -> Void)] {
1919
return [
2020
("test_equalWithAccuracy_passes", test_equalWithAccuracy_passes),
2121
("test_equalWithAccuracy_fails", test_equalWithAccuracy_fails),

Tests/Functional/Observation/All/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ XCTestObservationCenter.shared().addTestObserver(observer)
5656

5757
// CHECK: Test Suite 'Observation' started at \d+:\d+:\d+\.\d+
5858
class Observation: XCTestCase {
59-
static var allTests: [(String, Observation -> () throws -> Void)] {
59+
static var allTests: [(String, (Observation) -> () throws -> Void)] {
6060
return [
6161
("test_one", test_one),
6262
("test_two", test_two),

Tests/Functional/Observation/Selected/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let observer = Observer()
3737
XCTestObservationCenter.shared().addTestObserver(observer)
3838

3939
class SkippedTestCase: XCTestCase {
40-
static var allTests: [(String, SkippedTestCase -> () throws -> Void)] {
40+
static var allTests: [(String, (SkippedTestCase) -> () throws -> Void)] {
4141
return [
4242
("test_skipped", test_skipped),
4343
]
@@ -50,7 +50,7 @@ class SkippedTestCase: XCTestCase {
5050

5151
// CHECK: Test Suite 'ExecutedTestCase' started at \d+:\d+:\d+\.\d+
5252
class ExecutedTestCase: XCTestCase {
53-
static var allTests: [(String, ExecutedTestCase -> () throws -> Void)] {
53+
static var allTests: [(String, (ExecutedTestCase) -> () throws -> Void)] {
5454
return [
5555
("test_executed", test_executed),
5656
("test_skipped", test_skipped),

Tests/Functional/SelectedTest/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// CHECK-ALL: Test Suite '.*\.xctest' started at \d+:\d+:\d+\.\d+
1919

2020
class ExecutedTestCase: XCTestCase {
21-
static var allTests: [(String, ExecutedTestCase -> () throws -> Void)] {
21+
static var allTests: [(String, (ExecutedTestCase) -> () throws -> Void)] {
2222
return [
2323
("test_bar", test_bar),
2424
("test_foo", test_foo),
@@ -52,7 +52,7 @@ class ExecutedTestCase: XCTestCase {
5252

5353
// CHECK-ALL: Test Suite 'SkippedTestCase' started at \d+:\d+:\d+\.\d+
5454
class SkippedTestCase: XCTestCase {
55-
static var allTests: [(String, SkippedTestCase -> () throws -> Void)] {
55+
static var allTests: [(String, (SkippedTestCase) -> () throws -> Void)] {
5656
return [("test_baz", test_baz)]
5757
}
5858

Tests/Functional/SingleFailingTestCase/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// CHECK: Test Suite 'SingleFailingTestCase' started at \d+:\d+:\d+\.\d+
1515
class SingleFailingTestCase: XCTestCase {
16-
static var allTests: [(String, SingleFailingTestCase -> () throws -> Void)] {
16+
static var allTests: [(String, (SingleFailingTestCase) -> () throws -> Void)] {
1717
return [
1818
("test_fails", test_fails)
1919
]

Tests/Functional/TestCaseLifecycle/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// CHECK: Test Suite 'SetUpTearDownTestCase' started at \d+:\d+:\d+\.\d+
1515
class SetUpTearDownTestCase: XCTestCase {
16-
static var allTests: [(String, SetUpTearDownTestCase -> () throws -> Void)] {
16+
static var allTests: [(String, (SetUpTearDownTestCase) -> () throws -> Void)] {
1717
return [
1818
("test_hasValueFromSetUp", test_hasValueFromSetUp),
1919
]
@@ -60,7 +60,7 @@ class SetUpTearDownTestCase: XCTestCase {
6060

6161
// CHECK: Test Suite 'NewInstanceForEachTestTestCase' started at \d+:\d+:\d+\.\d+
6262
class NewInstanceForEachTestTestCase: XCTestCase {
63-
static var allTests: [(String, NewInstanceForEachTestTestCase -> () throws -> Void)] {
63+
static var allTests: [(String, (NewInstanceForEachTestTestCase) -> () throws -> Void)] {
6464
return [
6565
("test_hasInitializedValue", test_hasInitializedValue),
6666
("test_hasInitializedValueInAnotherTest", test_hasInitializedValueInAnotherTest),

0 commit comments

Comments
 (0)