Skip to content

Commit dabc9fd

Browse files
committed
Mark #expect(_:throws:) and #require(_:throws:) as to-be-deprecated.
These symbols should go through a transition period where they are documented as to-be-deprecated rather than being deprecated outright. My mistake. There is a bug in the DocC compiler that emits a diagnostic of the form: > ⚠️ 'require(_:sourceLocation:performing:throws:)' isn't unconditionally deprecated This issue is being tracked already with rdar://141785948. Resolves #873.
1 parent 5b4d6d6 commit dabc9fd

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

Diff for: Documentation/Proposals/0006-return-errors-from-expect-throws.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ is not statically available. The problematic overloads will also be deprecated:
105105
-) where E: Error & Equatable
106106
+) -> E where E: Error & Equatable
107107

108-
+@available(*, deprecated, message: "Examine the result of '#expect(throws:)' instead.")
108+
+@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#expect(throws:)' instead.")
109109
+@discardableResult
110110
@freestanding(expression) public macro expect<R>(
111111
_ comment: @autoclosure () -> Comment? = nil,
@@ -115,7 +115,7 @@ is not statically available. The problematic overloads will also be deprecated:
115115
-)
116116
+) -> (any Error)?
117117

118-
+@available(*, deprecated, message: "Examine the result of '#require(throws:)' instead.")
118+
+@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#require(throws:)' instead.")
119119
+@discardableResult
120120
@freestanding(expression) public macro require<R>(
121121
_ comment: @autoclosure () -> Comment? = nil,

Diff for: Sources/Testing/Expectations/Expectation+Macro.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public macro require<R>(
375375
/// ``expect(throws:_:sourceLocation:performing:)-1hfms`` instead. If the thrown
376376
/// error need only equal another instance of [`Error`](https://developer.apple.com/documentation/swift/error),
377377
/// use ``expect(throws:_:sourceLocation:performing:)-7du1h`` instead.
378-
@available(*, deprecated, message: "Examine the result of '#expect(throws:)' instead.")
378+
@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#expect(throws:)' instead.")
379379
@discardableResult
380380
@freestanding(expression) public macro expect<R>(
381381
_ comment: @autoclosure () -> Comment? = nil,
@@ -427,7 +427,7 @@ public macro require<R>(
427427
///
428428
/// If `expression` should _never_ throw, simply invoke the code without using
429429
/// this macro. The test will then fail if an error is thrown.
430-
@available(*, deprecated, message: "Examine the result of '#require(throws:)' instead.")
430+
@available(swift, introduced: 6.0, deprecated: 100000.0, message: "Examine the result of '#require(throws:)' instead.")
431431
@discardableResult
432432
@freestanding(expression) public macro require<R>(
433433
_ comment: @autoclosure () -> Comment? = nil,

Diff for: Sources/Testing/Testing.docc/AvailabilityStubs/ExpectComplexThrows.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

1313
@Metadata {
14-
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15-
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
14+
@Available(Swift, introduced: 6.0)
15+
@Available(Xcode, introduced: 16.0)
1616
}
1717

18-
@DeprecationSummary {
18+
@DeprecationSummary { <!-- Warning when compiling DocC: rdar://141785948 -->
1919
Examine the result of ``expect(throws:_:sourceLocation:performing:)-7du1h`` or
2020
``expect(throws:_:sourceLocation:performing:)-1hfms`` instead:
2121

Diff for: Sources/Testing/Testing.docc/AvailabilityStubs/RequireComplexThrows.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

1313
@Metadata {
14-
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15-
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
14+
@Available(Swift, introduced: 6.0)
15+
@Available(Xcode, introduced: 16.0)
1616
}
1717

18-
@DeprecationSummary {
18+
@DeprecationSummary { <!-- Warning when compiling DocC: rdar://141785948 -->
1919
Examine the result of ``require(throws:_:sourceLocation:performing:)-7n34r``
2020
or ``require(throws:_:sourceLocation:performing:)-4djuw`` instead:
2121

Diff for: Sources/Testing/Testing.docc/testing-for-errors-in-swift-code.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ running your test if the code doesn't throw the expected error.
4848

4949
To check that the code under test throws an error of any type, pass
5050
`(any Error).self` as the first argument to either
51-
``expect(throws:_:sourceLocation:performing:)-1xr34`` or
52-
``require(_:_:sourceLocation:)-5l63q``:
51+
``expect(throws:_:sourceLocation:performing:)-1hfms`` or
52+
``require(throws:_:sourceLocation:performing:)-7n34r``:
5353

5454
```swift
5555
@Test func cannotAddToppingToPizzaBeforeStartOfList() {

Diff for: Tests/TestingTests/IssueTests.swift

-8
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ final class IssueTests: XCTestCase {
491491
}.run(configuration: .init())
492492
}
493493

494-
@available(*, deprecated)
495494
func testErrorCheckingWithExpect() async throws {
496495
let expectationFailed = expectation(description: "Expectation failed")
497496
expectationFailed.isInverted = true
@@ -540,7 +539,6 @@ final class IssueTests: XCTestCase {
540539
await fulfillment(of: [expectationFailed], timeout: 0.0)
541540
}
542541

543-
@available(*, deprecated)
544542
func testErrorCheckingWithExpect_Mismatching() async throws {
545543
let expectationFailed = expectation(description: "Expectation failed")
546544
expectationFailed.expectedFulfillmentCount = 13
@@ -665,7 +663,6 @@ final class IssueTests: XCTestCase {
665663
await fulfillment(of: [expectationFailed], timeout: 0.0)
666664
}
667665

668-
@available(*, deprecated)
669666
func testErrorCheckingWithExpectAsync() async throws {
670667
let expectationFailed = expectation(description: "Expectation failed")
671668
expectationFailed.isInverted = true
@@ -709,7 +706,6 @@ final class IssueTests: XCTestCase {
709706
await fulfillment(of: [expectationFailed], timeout: 0.0)
710707
}
711708

712-
@available(*, deprecated)
713709
func testErrorCheckingWithExpectAsync_Mismatching() async throws {
714710
let expectationFailed = expectation(description: "Expectation failed")
715711
expectationFailed.expectedFulfillmentCount = 13
@@ -826,7 +822,6 @@ final class IssueTests: XCTestCase {
826822
await fulfillment(of: [expectationFailed], timeout: 0.0)
827823
}
828824

829-
@available(*, deprecated)
830825
func testErrorCheckingWithExpect_ThrowingFromErrorMatcher() async throws {
831826
let errorCaught = expectation(description: "Error matcher's error caught")
832827
let expectationFailed = expectation(description: "Expectation failed")
@@ -854,7 +849,6 @@ final class IssueTests: XCTestCase {
854849
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
855850
}
856851

857-
@available(*, deprecated)
858852
func testErrorCheckingWithExpectAsync_ThrowingFromErrorMatcher() async throws {
859853
let errorCaught = expectation(description: "Error matcher's error caught")
860854
let expectationFailed = expectation(description: "Expectation failed")
@@ -882,7 +876,6 @@ final class IssueTests: XCTestCase {
882876
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
883877
}
884878

885-
@available(*, deprecated)
886879
func testErrorCheckingWithRequire_ThrowingFromErrorMatcher() async throws {
887880
let errorCaught = expectation(description: "Error matcher's error caught")
888881
let expectationFailed = expectation(description: "Expectation failed")
@@ -911,7 +904,6 @@ final class IssueTests: XCTestCase {
911904
await fulfillment(of: [errorCaught, expectationFailed], timeout: 0.0)
912905
}
913906

914-
@available(*, deprecated)
915907
func testErrorCheckingWithRequireAsync_ThrowingFromErrorMatcher() async throws {
916908
let errorCaught = expectation(description: "Error matcher's error caught")
917909
let expectationFailed = expectation(description: "Expectation failed")

0 commit comments

Comments
 (0)