@@ -322,51 +322,50 @@ XCTestTestSuite.test("XCTAssertNoThrow") {
322
322
323
323
324
324
XCTestTestSuite . test ( " XCTAsserts with throwing expressions " ) {
325
- class ErrorTestCase : XCTestCase {
326
- var doThrow = true
327
- var errorCode = 42
328
-
329
- dynamic func throwSomething( ) throws -> String {
330
- if doThrow {
331
- throw NSError ( domain: " MyDomain " , code: errorCode, userInfo: nil )
332
- }
333
- return " Hello "
334
- }
335
-
336
- dynamic func test_withThrowing( ) {
337
- XCTAssertEqual ( try throwSomething ( ) , " Hello " )
338
- }
339
- }
340
-
341
- // Try success case
342
- do {
343
- let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_withThrowing) )
344
- testCase. doThrow = false
345
- execute ( testCase. run)
346
- let testRun = testCase. testRun!
347
-
348
- expectEqual ( 1 , testRun. testCaseCount)
349
- expectEqual ( 1 , testRun. executionCount)
350
- expectEqual ( 0 , testRun. failureCount)
351
- expectEqual ( 0 , testRun. unexpectedExceptionCount)
352
- expectEqual ( 0 , testRun. totalFailureCount)
353
- expectTrue ( testRun. hasSucceeded)
354
- }
355
-
356
- // Now try when the expression throws
357
- do {
358
- let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_withThrowing) )
359
- execute ( testCase. run)
360
- let testRun = testCase. testRun!
361
-
362
- expectEqual ( 1 , testRun. testCaseCount)
363
- expectEqual ( 1 , testRun. executionCount)
364
- expectEqual ( 0 , testRun. failureCount)
365
- expectEqual ( 1 , testRun. unexpectedExceptionCount)
366
- expectEqual ( 1 , testRun. totalFailureCount)
367
- expectFalse ( testRun. hasSucceeded)
368
- }
369
-
325
+ class ErrorTestCase : XCTestCase {
326
+ var doThrow = true
327
+ var errorCode = 42
328
+
329
+ dynamic func throwSomething( ) throws -> String {
330
+ if doThrow {
331
+ throw NSError ( domain: " MyDomain " , code: errorCode, userInfo: nil )
332
+ }
333
+ return " Hello "
334
+ }
335
+
336
+ dynamic func test_withThrowing( ) {
337
+ XCTAssertEqual ( try throwSomething ( ) , " Hello " )
338
+ }
339
+ }
340
+
341
+ // Try success case
342
+ do {
343
+ let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_withThrowing) )
344
+ testCase. doThrow = false
345
+ execute ( testCase. run)
346
+ let testRun = testCase. testRun!
347
+
348
+ expectEqual ( 1 , testRun. testCaseCount)
349
+ expectEqual ( 1 , testRun. executionCount)
350
+ expectEqual ( 0 , testRun. failureCount)
351
+ expectEqual ( 0 , testRun. unexpectedExceptionCount)
352
+ expectEqual ( 0 , testRun. totalFailureCount)
353
+ expectTrue ( testRun. hasSucceeded)
354
+ }
355
+
356
+ // Now try when the expression throws
357
+ do {
358
+ let testCase = ErrorTestCase ( selector: #selector( ErrorTestCase . test_withThrowing) )
359
+ execute ( testCase. run)
360
+ let testRun = testCase. testRun!
361
+
362
+ expectEqual ( 1 , testRun. testCaseCount)
363
+ expectEqual ( 1 , testRun. executionCount)
364
+ expectEqual ( 0 , testRun. failureCount)
365
+ expectEqual ( 1 , testRun. unexpectedExceptionCount)
366
+ expectEqual ( 1 , testRun. totalFailureCount)
367
+ expectFalse ( testRun. hasSucceeded)
368
+ }
370
369
}
371
370
372
371
XCTestTestSuite . test ( " Test methods that wind up throwing " ) {
0 commit comments