Merge pull request #166 from briancroom/discardable-result
Add @discardableResult annotation to applicable public API methods.
diff --git a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
index 09ee88f..7380db7 100644
--- a/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
+++ b/Sources/XCTest/Public/XCTestCase+Asynchronous.swift
@@ -39,7 +39,7 @@
/// between these environments. To ensure compatibility of tests between
/// swift-corelibs-xctest and Apple XCTest, it is not recommended to pass
/// explicit values for `file` and `line`.
- func expectation(description: String, file: StaticString = #file, line: UInt = #line) -> XCTestExpectation {
+ @discardableResult func expectation(description: String, file: StaticString = #file, line: UInt = #line) -> XCTestExpectation {
let expectation = XCTestExpectation(
description: description,
file: file,
@@ -164,7 +164,7 @@
/// notification is observed. It will not be invoked on timeout. Use the
/// handler to further investigate if the notification fulfills the
/// expectation.
- func expectation(forNotification notificationName: String, object objectToObserve: AnyObject?, handler: XCNotificationExpectationHandler? = nil) -> XCTestExpectation {
+ @discardableResult func expectation(forNotification notificationName: String, object objectToObserve: AnyObject?, handler: XCNotificationExpectationHandler? = nil) -> XCTestExpectation {
let objectDescription = objectToObserve == nil ? "any object" : "\(objectToObserve!)"
let expectation = self.expectation(description: "Expect notification '\(notificationName)' from " + objectDescription)
// Start observing the notification with specified name and object.
@@ -226,7 +226,7 @@
/// first successful evaluation will fulfill the expectation. If provided,
/// the handler can override that behavior which leaves the caller
/// responsible for fulfilling the expectation.
- func expectation(for predicate: NSPredicate, evaluatedWith object: AnyObject, file: StaticString = #file, line: UInt = #line, handler: XCPredicateExpectationHandler? = nil) -> XCTestExpectation {
+ @discardableResult func expectation(for predicate: NSPredicate, evaluatedWith object: AnyObject, file: StaticString = #file, line: UInt = #line, handler: XCPredicateExpectationHandler? = nil) -> XCTestExpectation {
let expectation = XCPredicateExpectation(
predicate: predicate,
object: object,