@@ -1030,28 +1030,17 @@ public func XCTAssertThrowsError<T>(_ expression: @autoclosure () throws -> T, _
1030
1030
}
1031
1031
}
1032
1032
1033
- public func XCTAssertNoThrow< T> ( _ expression: @autoclosure ( ) throws -> T , _ message: @autoclosure ( ) -> String = " " , file: StaticString = #file, line: UInt = #line, _ errorHandler : ( _ error : Error ) -> Void = { _ in } ) {
1033
+ public func XCTAssertNoThrow< T> ( _ expression: @autoclosure ( ) throws -> T , _ message: @autoclosure ( ) -> String = " " , file: StaticString = #file, line: UInt = #line) {
1034
1034
let assertionType = _XCTAssertionType. assertion_NoThrow
1035
1035
1036
- // evaluate expression exactly once
1037
- var caughtErrorOptional : Error ?
1038
-
1039
- let result = _XCTRunThrowableBlock {
1040
- do {
1041
- _ = try expression ( )
1042
- } catch {
1043
- caughtErrorOptional = error
1044
- }
1045
- }
1036
+ let result = _XCTRunThrowableBlock { _ = try expression ( ) }
1046
1037
1047
1038
switch result {
1048
1039
case . success:
1049
- guard let caughtError = caughtErrorOptional else {
1040
+ guard let error = error else {
1050
1041
return
1051
1042
}
1052
1043
1053
- _XCTRegisterFailure ( true , " XCTAssertNoThrow failed: threw error \" \( caughtError) \" " , message, file, line)
1054
-
1055
1044
case . failedWithError( let error) :
1056
1045
_XCTRegisterFailure ( true , " XCTAssertNoThrow failed: threw error \" \( error) \" " , message, file, line)
1057
1046
@@ -1061,7 +1050,6 @@ public func XCTAssertNoThrow<T>(_ expression: @autoclosure () throws -> T, _ mes
1061
1050
case . failedWithUnknownException:
1062
1051
_XCTRegisterFailure ( true , _XCTFailureDescription ( assertionType, 2 ) , message, file, line)
1063
1052
}
1064
-
1065
1053
}
1066
1054
1067
1055
#if XCTEST_ENABLE_EXCEPTION_ASSERTIONS
0 commit comments