20
20
/// - ``Trait/disabled(_:sourceLocation:_:)``
21
21
public struct ConditionTrait : TestTrait , SuiteTrait {
22
22
/// The result of evaluating the condition.
23
- public typealias Evaluation = ( Bool , comment: Comment ? )
24
-
23
+ ///
24
+ /// - Parameters:
25
+ /// - wasMet: Whether or not the condition was met.
26
+ /// - comment: Optionally, a comment describing the result of evaluating the condition.
27
+ @_spi ( Experimental)
28
+ public typealias EvaluationResult = ( wasMet: Bool , comment: Comment ? )
29
+
25
30
/// An enumeration describing the kinds of conditions that can be represented
26
31
/// by an instance of this type.
27
32
enum Kind : Sendable {
@@ -33,7 +38,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
33
38
/// `false` and a comment is also returned, it is used in place of the
34
39
/// value of the associated trait's ``ConditionTrait/comment`` property.
35
40
/// If this function returns `true`, the returned comment is ignored.
36
- case conditional( _ body: @Sendable ( ) async throws -> Evaluation )
41
+ case conditional( _ body: @Sendable ( ) async throws -> EvaluationResult )
37
42
38
43
/// Create an instance of this type associated with a trait that is
39
44
/// conditional on the result of calling a function.
@@ -44,7 +49,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
44
49
///
45
50
/// - Returns: An instance of this type.
46
51
static func conditional( _ body: @escaping @Sendable ( ) async throws -> Bool ) -> Self {
47
- conditional { ( ) -> Evaluation in
52
+ conditional { ( ) -> EvaluationResult in
48
53
return ( try await body ( ) , nil )
49
54
}
50
55
}
@@ -83,9 +88,14 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
83
88
/// The source location where this trait was specified.
84
89
public var sourceLocation : SourceLocation
85
90
86
- /// Returns the result of evaluating the condition.
91
+ /// Evaluate this instance's underlying condition.
92
+ ///
93
+ /// - Returns: The result of evaluating this instance's underlying condition.
94
+ ///
95
+ /// The evaluation is performed each time this function is called, and is not
96
+ /// cached.
87
97
@_spi ( Experimental)
88
- public func evaluate( ) async throws -> Evaluation {
98
+ public func evaluate( ) async throws -> EvaluationResult {
89
99
switch kind {
90
100
case let . conditional( condition) :
91
101
try await condition ( )
0 commit comments