mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #6776 from ArtSabintsev/feature/XCTAssertNoThrow
Implementation for XCTAssertNoThrow
This commit is contained in:
@@ -1030,6 +1030,26 @@ public func XCTAssertThrowsError<T>(_ expression: @autoclosure () throws -> T, _
|
||||
}
|
||||
}
|
||||
|
||||
public func XCTAssertNoThrow<T>(_ expression: @autoclosure () throws -> T, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) {
|
||||
let assertionType = _XCTAssertionType.noThrow
|
||||
|
||||
let result = _XCTRunThrowableBlock { _ = try expression() }
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
return
|
||||
|
||||
case .failedWithError(let error):
|
||||
_XCTRegisterFailure(true, "XCTAssertNoThrow failed: threw error \"\(error)\"", message, file, line)
|
||||
|
||||
case .failedWithException(_, _, let reason):
|
||||
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 1, reason as NSString), message, file, line)
|
||||
|
||||
case .failedWithUnknownException:
|
||||
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 2), message, file, line)
|
||||
}
|
||||
}
|
||||
|
||||
#if XCTEST_ENABLE_EXCEPTION_ASSERTIONS
|
||||
// --- Currently-Unsupported Assertions ---
|
||||
|
||||
@@ -1051,12 +1071,6 @@ public func XCTAssertThrowsSpecificNamed(_ expression: @autoclosure () -> Any?,
|
||||
// FIXME: Unsupported
|
||||
}
|
||||
|
||||
public func XCTAssertNoThrow(_ expression: @autoclosure () -> Any?, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) {
|
||||
let assertionType = _XCTAssertionType.assertion_NoThrow
|
||||
|
||||
// FIXME: Unsupported
|
||||
}
|
||||
|
||||
public func XCTAssertNoThrowSpecific(_ expression: @autoclosure () -> Any?, _ exception: Any, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) {
|
||||
let assertionType = _XCTAssertionType.assertion_NoThrowSpecific
|
||||
|
||||
|
||||
Reference in New Issue
Block a user