8
8
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
//
10
10
11
- /// A type that defines a condition which must be satisfied for a test to be
12
- /// enabled .
11
+ /// A type that defines a condition which must be satisfied for the testing
12
+ /// library to enable a test .
13
13
///
14
14
/// To add this trait to a test, use one of the following functions:
15
15
///
19
19
/// - ``Trait/disabled(if:_:sourceLocation:)``
20
20
/// - ``Trait/disabled(_:sourceLocation:_:)``
21
21
public struct ConditionTrait : TestTrait , SuiteTrait {
22
- /// An enumeration describing the kinds of conditions that can be represented
23
- /// by an instance of this type .
22
+ /// An enumeration that describes the conditions that an instance of this type
23
+ /// can represent .
24
24
enum Kind : Sendable {
25
- /// The trait is conditional on the result of calling a function.
25
+ /// Enabling the test is conditional on the result of calling a function.
26
26
///
27
27
/// - Parameters:
28
28
/// - body: The function to call. The result of this function determines
@@ -39,7 +39,8 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
39
39
/// - body: The function to call. The result of this function determines
40
40
/// whether or not the condition was met.
41
41
///
42
- /// - Returns: An instance of this type.
42
+ /// - Returns: A trait that marks a test's enabled status as the result of
43
+ /// calling a function.
43
44
static func conditional( _ body: @escaping @Sendable ( ) async throws -> Bool ) -> Self {
44
45
conditional { ( ) -> ( Bool , comment: Comment ? ) in
45
46
return ( try await body ( ) , nil )
@@ -49,14 +50,14 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
49
50
/// The trait is unconditional and always has the same result.
50
51
///
51
52
/// - Parameters:
52
- /// - value: Whether or not the condition was met .
53
+ /// - value: Whether or not the test is enabled .
53
54
case unconditional( _ value: Bool )
54
55
}
55
56
56
- /// The kind of condition represented by this instance .
57
+ /// The kind of condition represented by this trait .
57
58
var kind : Kind
58
59
59
- /// Whether or not this trait has a condition that is evaluated at runtime.
60
+ /// Whether this trait's condition is constant, or evaluated at runtime.
60
61
///
61
62
/// If this trait was created using a function such as
62
63
/// ``disabled(_:sourceLocation:)`` that unconditionally enables or disables a
@@ -77,7 +78,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
77
78
78
79
public var comments : [ Comment ]
79
80
80
- /// The source location where this trait was specified.
81
+ /// The source location where this trait is specified.
81
82
public var sourceLocation : SourceLocation
82
83
83
84
public func prepare( for test: Test ) async throws {
@@ -110,24 +111,23 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
110
111
// MARK: -
111
112
112
113
extension Trait where Self == ConditionTrait {
113
- /// Construct a condition trait that causes a test to be disabled if it
114
- /// returns `false`.
114
+ /// Constructs a condition trait that disables a test if it returns `false`.
115
115
///
116
116
/// - Parameters:
117
- /// - condition: A closure containing the trait's custom condition logic. If
118
- /// this closure returns `true`, the test is allowed to run. Otherwise,
119
- /// the test is skipped .
120
- /// - comment: An optional, user-specified comment describing this trait.
117
+ /// - condition: A closure that contains the trait's custom condition logic.
118
+ /// If this closure returns `true`, the trait allows the test to run.
119
+ /// Otherwise, the testing library skips the test .
120
+ /// - comment: An optional comment that describes this trait.
121
121
/// - sourceLocation: The source location of the trait.
122
122
///
123
- /// - Returns: An instance of ``ConditionTrait`` that will evaluate the
124
- /// specified closure.
125
- ///
126
- /// @Comment {
127
- /// - Bug: `condition` cannot be `async` without making this function
128
- /// `async` even though `condition` is not evaluated locally.
129
- /// ([103037177](rdar://103037177))
130
- /// }
123
+ /// - Returns: An instance of ``ConditionTrait`` that evaluates the
124
+ /// closure you provide .
125
+ //
126
+ // @Comment {
127
+ // - Bug: `condition` cannot be `async` without making this function
128
+ // `async` even though `condition` is not evaluated locally.
129
+ // ([103037177](rdar://103037177))
130
+ // }
131
131
public static func enabled(
132
132
if condition: @autoclosure @escaping @Sendable ( ) throws -> Bool ,
133
133
_ comment: Comment ? = nil ,
@@ -136,18 +136,17 @@ extension Trait where Self == ConditionTrait {
136
136
Self ( kind: . conditional( condition) , comments: Array ( comment) , sourceLocation: sourceLocation)
137
137
}
138
138
139
- /// Construct a condition trait that causes a test to be disabled if it
140
- /// returns `false`.
139
+ /// Constructs a condition trait that disables a test if it returns `false`.
141
140
///
142
141
/// - Parameters:
143
- /// - comment: An optional, user-specified comment describing this trait.
142
+ /// - comment: An optional comment that describes this trait.
144
143
/// - sourceLocation: The source location of the trait.
145
- /// - condition: A closure containing the trait's custom condition logic. If
146
- /// this closure returns `true`, the test is allowed to run. Otherwise,
147
- /// the test is skipped .
144
+ /// - condition: A closure that contains the trait's custom condition logic.
145
+ /// If this closure returns `true`, the trait allows the test to run.
146
+ /// Otherwise, the testing library skips the test .
148
147
///
149
- /// - Returns: An instance of ``ConditionTrait`` that will evaluate the
150
- /// specified closure.
148
+ /// - Returns: An instance of ``ConditionTrait`` that evaluates the
149
+ /// closure you provide .
151
150
public static func enabled(
152
151
_ comment: Comment ? = nil ,
153
152
sourceLocation: SourceLocation = #_sourceLocation,
@@ -156,13 +155,13 @@ extension Trait where Self == ConditionTrait {
156
155
Self ( kind: . conditional( condition) , comments: Array ( comment) , sourceLocation: sourceLocation)
157
156
}
158
157
159
- /// Construct a condition trait that disables a test unconditionally.
158
+ /// Constructs a condition trait that disables a test unconditionally.
160
159
///
161
160
/// - Parameters:
162
- /// - comment: An optional, user-specified comment describing this trait.
161
+ /// - comment: An optional comment that describes this trait.
163
162
/// - sourceLocation: The source location of the trait.
164
163
///
165
- /// - Returns: An instance of ``ConditionTrait`` that will always disable the
164
+ /// - Returns: An instance of ``ConditionTrait`` that always disables the
166
165
/// test to which it is added.
167
166
public static func disabled(
168
167
_ comment: Comment ? = nil ,
@@ -171,24 +170,23 @@ extension Trait where Self == ConditionTrait {
171
170
Self ( kind: . unconditional( false ) , comments: Array ( comment) , sourceLocation: sourceLocation)
172
171
}
173
172
174
- /// Construct a condition trait that causes a test to be disabled if it
175
- /// returns `true`.
173
+ /// Constructs a condition trait that disables a test if its value is true.
176
174
///
177
175
/// - Parameters:
178
- /// - condition: A closure containing the trait's custom condition logic. If
179
- /// this closure returns `false`, the test is allowed to run. Otherwise,
180
- /// the test is skipped .
181
- /// - comment: An optional, user-specified comment describing this trait.
176
+ /// - condition: A closure that contains the trait's custom condition logic.
177
+ /// If this closure returns `false`, the trait allows the test to run.
178
+ /// Otherwise, the testing library skips the test .
179
+ /// - comment: An optional comment that describes this trait.
182
180
/// - sourceLocation: The source location of the trait.
183
181
///
184
- /// - Returns: An instance of ``ConditionTrait`` that will evaluate the
185
- /// specified closure.
186
- ///
187
- /// @Comment {
188
- /// - Bug: `condition` cannot be `async` without making this function
189
- /// `async` even though `condition` is not evaluated locally.
190
- /// ([103037177](rdar://103037177))
191
- /// }
182
+ /// - Returns: An instance of ``ConditionTrait`` that evaluates the
183
+ /// closure you provide .
184
+ //
185
+ // @Comment {
186
+ // - Bug: `condition` cannot be `async` without making this function
187
+ // `async` even though `condition` is not evaluated locally.
188
+ // ([103037177](rdar://103037177))
189
+ // }
192
190
public static func disabled(
193
191
if condition: @autoclosure @escaping @Sendable ( ) throws -> Bool ,
194
192
_ comment: Comment ? = nil ,
@@ -197,17 +195,16 @@ extension Trait where Self == ConditionTrait {
197
195
Self ( kind: . conditional { !( try condition ( ) ) } , comments: Array ( comment) , sourceLocation: sourceLocation)
198
196
}
199
197
200
- /// Construct a condition trait that causes a test to be disabled if it
201
- /// returns `true`.
198
+ /// Constructs a condition trait that disables a test if its value is true.
202
199
///
203
200
/// - Parameters:
204
- /// - comment: An optional, user-specified comment describing this trait.
201
+ /// - comment: An optional comment that describes this trait.
205
202
/// - sourceLocation: The source location of the trait.
206
- /// - condition: A closure containing the trait's custom condition logic. If
207
- /// this closure returns `false`, the test is allowed to run. Otherwise,
208
- /// the test is skipped .
203
+ /// - condition: A closure that contains the trait's custom condition logic.
204
+ /// If this closure returns `false`, the trait allows the test to run.
205
+ /// Otherwise, the testing library skips the test .
209
206
///
210
- /// - Returns: An instance of ``ConditionTrait`` that will evaluate the
207
+ /// - Returns: An instance of ``ConditionTrait`` that evaluates the
211
208
/// specified closure.
212
209
public static func disabled(
213
210
_ comment: Comment ? = nil ,
0 commit comments