File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ func callExitTest(
236
236
isRequired: Bool ,
237
237
isolation: isolated ( any Actor ) ? = #isolation,
238
238
sourceLocation: SourceLocation
239
- ) async -> Result < ExitTestArtifacts , any Error > {
239
+ ) async -> Result < ExitTestArtifacts ? , any Error > {
240
240
guard let configuration = Configuration . current ?? Configuration . all. first else {
241
241
preconditionFailure ( " A test must be running on the current task to use #expect(exitsWith:). " )
242
242
}
Original file line number Diff line number Diff line change @@ -1149,7 +1149,7 @@ public func __checkClosureCall(
1149
1149
isRequired: Bool ,
1150
1150
isolation: isolated ( any Actor ) ? = #isolation,
1151
1151
sourceLocation: SourceLocation
1152
- ) async -> Result < ExitTestArtifacts , any Error > {
1152
+ ) async -> Result < ExitTestArtifacts ? , any Error > {
1153
1153
await callExitTest (
1154
1154
exitsWith: expectedExitCondition,
1155
1155
observing: observedValues,
Original file line number Diff line number Diff line change @@ -15,19 +15,32 @@ extension Result {
15
15
/// `#require()` macros. Do not call it directly.
16
16
@inlinable public func __expected( ) where Success == Void { }
17
17
18
+ /// Handle this instance as if it were returned from a call to `#require()`.
19
+ ///
20
+ /// - Warning: This function is used to implement the `#expect()` and
21
+ /// `#require()` macros. Do not call it directly.
22
+ @inlinable public func __required( ) throws -> Success {
23
+ try get ( )
24
+ }
25
+ }
26
+
27
+ // MARK: - Optional success values
28
+
29
+ extension Result {
18
30
/// Handle this instance as if it were returned from a call to `#expect()`.
19
31
///
20
32
/// - Warning: This function is used to implement the `#expect()` and
21
33
/// `#require()` macros. Do not call it directly.
22
- @inlinable public func __expected( ) -> Success ? {
34
+ @inlinable public func __expected< T > ( ) -> Success where Success == T ? {
23
35
try ? get ( )
24
36
}
25
37
26
38
/// Handle this instance as if it were returned from a call to `#require()`.
27
39
///
28
40
/// - Warning: This function is used to implement the `#expect()` and
29
41
/// `#require()` macros. Do not call it directly.
30
- @inlinable public func __required( ) throws -> Success {
31
- try get ( )
42
+ @inlinable public func __required< T> ( ) throws -> T where Success == T ? {
43
+ // TODO: handle edge case where the value is nil (see #780)
44
+ try get ( ) !
32
45
}
33
46
}
You can’t perform that action at this time.
0 commit comments