@@ -3,78 +3,78 @@ import Dispatch
3
3
#endif
4
4
5
5
/// Make an ``AsyncExpectation`` on a given actual value. The value given is lazily evaluated.
6
- public func expect< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @escaping @Sendable ( ) async throws -> T ? ) -> AsyncExpectation < T > {
6
+ public func expect< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @escaping @Sendable ( ) async throws -> T ? ) -> AsyncExpectation < T > {
7
7
return AsyncExpectation (
8
8
expression: AsyncExpression (
9
9
expression: expression,
10
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
10
+ location: location ,
11
11
isClosure: true ) )
12
12
}
13
13
14
14
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
15
- public func expect< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> T ) ) -> AsyncExpectation < T > {
15
+ public func expect< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> T ) ) -> AsyncExpectation < T > {
16
16
return AsyncExpectation (
17
17
expression: AsyncExpression (
18
18
expression: expression ( ) ,
19
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
19
+ location: location ,
20
20
isClosure: true ) )
21
21
}
22
22
23
23
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
24
- public func expect< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> T ? ) ) -> AsyncExpectation < T > {
24
+ public func expect< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> T ? ) ) -> AsyncExpectation < T > {
25
25
return AsyncExpectation (
26
26
expression: AsyncExpression (
27
27
expression: expression ( ) ,
28
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
28
+ location: location ,
29
29
isClosure: true ) )
30
30
}
31
31
32
32
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
33
- public func expect( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> Void ) ) -> AsyncExpectation < Void > {
33
+ public func expect( location : SourceLocation = SourceLocation ( ) , _ expression: @Sendable ( ) -> ( @Sendable ( ) async throws -> Void ) ) -> AsyncExpectation < Void > {
34
34
return AsyncExpectation (
35
35
expression: AsyncExpression (
36
36
expression: expression ( ) ,
37
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
37
+ location: location ,
38
38
isClosure: true ) )
39
39
}
40
40
41
41
/// Make an ``AsyncExpectation`` on a given actual value. The value given is lazily evaluated.
42
42
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`.
43
- public func expecta< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @autoclosure @escaping @Sendable ( ) async throws -> T ? ) async -> AsyncExpectation < T > {
43
+ public func expecta< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @autoclosure @escaping @Sendable ( ) async throws -> T ? ) async -> AsyncExpectation < T > {
44
44
return AsyncExpectation (
45
45
expression: AsyncExpression (
46
46
expression: expression,
47
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
47
+ location: location ,
48
48
isClosure: true ) )
49
49
}
50
50
51
51
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
52
52
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
53
- public func expecta< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> T ) ) async -> AsyncExpectation < T > {
53
+ public func expecta< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> T ) ) async -> AsyncExpectation < T > {
54
54
return AsyncExpectation (
55
55
expression: AsyncExpression (
56
56
expression: expression ( ) ,
57
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
57
+ location: location ,
58
58
isClosure: true ) )
59
59
}
60
60
61
61
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
62
62
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
63
- public func expecta< T: Sendable > ( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> T ? ) ) async -> AsyncExpectation < T > {
63
+ public func expecta< T: Sendable > ( location : SourceLocation = SourceLocation ( ) , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> T ? ) ) async -> AsyncExpectation < T > {
64
64
return AsyncExpectation (
65
65
expression: AsyncExpression (
66
66
expression: expression ( ) ,
67
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
67
+ location: location ,
68
68
isClosure: true ) )
69
69
}
70
70
71
71
/// Make an ``AsyncExpectation`` on a given actual value. The closure is lazily invoked.
72
72
/// This is provided to avoid confusion between `expect -> SyncExpectation` and `expect -> AsyncExpectation`
73
- public func expecta( fileID : String = #fileID , file : FileString = #filePath , line : UInt = #line , column : UInt = #column , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> Void ) ) async -> AsyncExpectation < Void > {
73
+ public func expecta( location : SourceLocation = SourceLocation ( ) , _ expression: @autoclosure @Sendable ( ) -> ( @Sendable ( ) async throws -> Void ) ) async -> AsyncExpectation < Void > {
74
74
return AsyncExpectation (
75
75
expression: AsyncExpression (
76
76
expression: expression ( ) ,
77
- location: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column ) ,
77
+ location: location ,
78
78
isClosure: true ) )
79
79
}
80
80
@@ -89,15 +89,12 @@ public func expecta(fileID: String = #fileID, file: FileString = #filePath, line
89
89
/// Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
90
90
public func waitUntil(
91
91
timeout: NimbleTimeInterval = PollingDefaults . timeout,
92
- fileID: String = #fileID,
93
- file: FileString = #filePath,
94
- line: UInt = #line,
95
- column: UInt = #column,
92
+ location: SourceLocation = SourceLocation ( ) ,
96
93
action: @escaping @Sendable ( @escaping @Sendable ( ) -> Void ) async -> Void
97
94
) async {
98
95
await throwableUntil (
99
96
timeout: timeout,
100
- sourceLocation: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column )
97
+ sourceLocation: location
101
98
) { done in
102
99
await action ( done)
103
100
}
@@ -112,15 +109,12 @@ public func waitUntil(
112
109
/// Unlike the synchronous version of this call, this does not support catching Objective-C exceptions.
113
110
public func waitUntil(
114
111
timeout: NimbleTimeInterval = PollingDefaults . timeout,
115
- fileID: String = #fileID,
116
- file: FileString = #filePath,
117
- line: UInt = #line,
118
- column: UInt = #column,
112
+ location: SourceLocation = SourceLocation ( ) ,
119
113
action: @escaping @Sendable ( @escaping @Sendable ( ) -> Void ) -> Void
120
114
) async {
121
115
await throwableUntil (
122
116
timeout: timeout,
123
- sourceLocation: SourceLocation ( fileID : fileID , filePath : file , line : line , column : column )
117
+ sourceLocation: location
124
118
) { done in
125
119
action ( done)
126
120
}
@@ -154,34 +148,22 @@ private func throwableUntil(
154
148
case . blockedRunLoop:
155
149
fail (
156
150
blockedRunLoopErrorMessageFor ( " -waitUntil() " , leeway: leeway) ,
157
- fileID: sourceLocation. fileID,
158
- file: sourceLocation. filePath,
159
- line: sourceLocation. line,
160
- column: sourceLocation. column
151
+ location: sourceLocation
161
152
)
162
153
case . timedOut:
163
154
fail (
164
155
" Waited more than \( timeout. description) " ,
165
- fileID: sourceLocation. fileID,
166
- file: sourceLocation. filePath,
167
- line: sourceLocation. line,
168
- column: sourceLocation. column
156
+ location: sourceLocation
169
157
)
170
158
case let . errorThrown( error) :
171
159
fail (
172
160
" Unexpected error thrown: \( error) " ,
173
- fileID: sourceLocation. fileID,
174
- file: sourceLocation. filePath,
175
- line: sourceLocation. line,
176
- column: sourceLocation. column
161
+ location: sourceLocation
177
162
)
178
163
case . completed( . error( let error) ) :
179
164
fail (
180
165
" Unexpected error thrown: \( error) " ,
181
- fileID: sourceLocation. fileID,
182
- file: sourceLocation. filePath,
183
- line: sourceLocation. line,
184
- column: sourceLocation. column
166
+ location: sourceLocation
185
167
)
186
168
case . completed( . none) : // success
187
169
break
0 commit comments