Skip to content

Commit d4e9db1

Browse files
committed
Deprecate double-closure variants of #expect/#require
1 parent b9e6594 commit d4e9db1

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -375,6 +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.")
378379
@discardableResult
379380
@freestanding(expression) public macro expect<R>(
380381
_ comment: @autoclosure () -> Comment? = nil,
@@ -426,6 +427,7 @@ public macro require<R>(
426427
///
427428
/// If `expression` should _never_ throw, simply invoke the code without using
428429
/// this macro. The test will then fail if an error is thrown.
430+
@available(*, deprecated, message: "Examine the result of '#require(throws:)' instead.")
429431
@discardableResult
430432
@freestanding(expression) public macro require<R>(
431433
_ comment: @autoclosure () -> Comment? = nil,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ``expect(_:sourceLocation:performing:throws:)``
2+
3+
<!--
4+
This source file is part of the Swift.org open source project
5+
6+
Copyright (c) 2023 Apple Inc. and the Swift project authors
7+
Licensed under Apache License v2.0 with Runtime Library Exception
8+
9+
See https://swift.org/LICENSE.txt for license information
10+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
11+
-->
12+
13+
@Metadata {
14+
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15+
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
16+
}
17+
18+
@DeprecationSummary {
19+
Examine the result of ``expect(throws:_:sourceLocation:performing:)-7du1h`` or
20+
``expect(throws:_:sourceLocation:performing:)-1hfms`` instead:
21+
22+
```swift
23+
let error = #expect(throws: FoodTruckError.self) {
24+
...
25+
}
26+
#expect(error?.napkinCount == 0)
27+
```
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ``require(_:sourceLocation:performing:throws:)``
2+
3+
<!--
4+
This source file is part of the Swift.org open source project
5+
6+
Copyright (c) 2023 Apple Inc. and the Swift project authors
7+
Licensed under Apache License v2.0 with Runtime Library Exception
8+
9+
See https://swift.org/LICENSE.txt for license information
10+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
11+
-->
12+
13+
@Metadata {
14+
@Available(Swift, introduced: 6.0, deprecated: 999.0)
15+
@Available(Xcode, introduced: 16.0, deprecated: 999.0)
16+
}
17+
18+
@DeprecationSummary {
19+
Examine the result of ``require(throws:_:sourceLocation:performing:)-7n34r``
20+
or ``require(throws:_:sourceLocation:performing:)-4djuw`` instead:
21+
22+
```swift
23+
let error = try #require(throws: FoodTruckError.self) {
24+
...
25+
}
26+
#expect(error.napkinCount == 0)
27+
```
28+
}

0 commit comments

Comments
 (0)