Skip to content

Commit 6c84190

Browse files
committed
Change name and add comments
1 parent 2922f02 commit 6c84190

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Sources/Testing/Traits/ConditionTrait.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020
/// - ``Trait/disabled(_:sourceLocation:_:)``
2121
public struct ConditionTrait: TestTrait, SuiteTrait {
2222
/// 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+
2530
/// An enumeration describing the kinds of conditions that can be represented
2631
/// by an instance of this type.
2732
enum Kind: Sendable {
@@ -33,7 +38,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
3338
/// `false` and a comment is also returned, it is used in place of the
3439
/// value of the associated trait's ``ConditionTrait/comment`` property.
3540
/// 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)
3742

3843
/// Create an instance of this type associated with a trait that is
3944
/// conditional on the result of calling a function.
@@ -44,7 +49,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
4449
///
4550
/// - Returns: An instance of this type.
4651
static func conditional(_ body: @escaping @Sendable () async throws -> Bool) -> Self {
47-
conditional { () -> Evaluation in
52+
conditional { () -> EvaluationResult in
4853
return (try await body(), nil)
4954
}
5055
}
@@ -83,9 +88,14 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
8388
/// The source location where this trait was specified.
8489
public var sourceLocation: SourceLocation
8590

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.
8797
@_spi(Experimental)
88-
public func evaluate() async throws -> Evaluation {
98+
public func evaluate() async throws -> EvaluationResult {
8999
switch kind {
90100
case let .conditional(condition):
91101
try await condition()

0 commit comments

Comments
 (0)