Skip to content

Commit c5eba93

Browse files
authored
Rename Expression to __Expression. (#373)
This PR renames the `Expression` type, which represents source code and syntax captured during macro expansion, so that it does not conflict with Foundation's [`Expression`](https://github.com/apple/swift-foundation/blob/main/Sources/FoundationEssentials/Predicate/Expression.swift) type used with predicates. We also expose a typealias to `__Expression` for use when integrating with tools that care about captured source code (e.g. to present it in their output.) Resolves rdar://125988077. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 9a0102a commit c5eba93

File tree

12 files changed

+106
-89
lines changed

12 files changed

+106
-89
lines changed

Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ extension Event.HumanReadableOutputRecorder {
370370

371371
if verbose, case let .expectationFailed(expectation) = issue.kind {
372372
let expression = expectation.evaluatedExpression
373-
func addMessage(about expression: Expression) {
373+
func addMessage(about expression: __Expression) {
374374
let description = expression.expandedDebugDescription()
375375
additionalMessages.append(Message(symbol: .details, stringValue: description))
376376
}

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ extension ExitTest {
132132
func callExitTest(
133133
exitsWith expectedExitCondition: ExitCondition,
134134
performing body: @escaping @Sendable () async -> Void,
135-
expression: Expression,
135+
expression: __Expression,
136136
comments: @autoclosure () -> [Comment],
137137
isRequired: Bool,
138138
sourceLocation: SourceLocation

Sources/Testing/Expectations/Expectation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/// A type describing an expectation that has been evaluated.
1212
public struct Expectation: Sendable {
1313
/// The expression evaluated by this expectation.
14+
@_spi(ForToolsIntegrationOnly)
1415
public var evaluatedExpression: Expression
1516

1617
/// A description of the error mismatch that occurred, if any.
@@ -65,7 +66,6 @@ extension Expectation {
6566
///
6667
/// If this expectation passed, the value of this property is `nil` because no
6768
/// error mismatch occurred.
68-
@_spi(ForToolsIntegrationOnly)
6969
public var mismatchedErrorDescription: String?
7070

7171
/// A description of the difference between the operands in the expression
@@ -74,7 +74,6 @@ extension Expectation {
7474
/// If this expectation passed, the value of this property is `nil` because
7575
/// the difference is only computed when necessary to assist with diagnosing
7676
/// test failures.
77-
@_spi(ForToolsIntegrationOnly)
7877
public var differenceDescription: String?
7978

8079
/// Whether the expectation passed or failed.

Sources/Testing/Expectations/ExpectationChecking+Macro.swift

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
/// `#require()` macros. Do not call it directly.
6161
public func __checkValue(
6262
_ condition: Bool,
63-
expression: Expression,
64-
expressionWithCapturedRuntimeValues: @autoclosure () -> Expression? = nil,
63+
expression: __Expression,
64+
expressionWithCapturedRuntimeValues: @autoclosure () -> __Expression? = nil,
6565
mismatchedErrorDescription: @autoclosure () -> String? = nil,
6666
difference: @autoclosure () -> String? = nil,
6767
comments: @autoclosure () -> [Comment],
@@ -73,7 +73,7 @@ public func __checkValue(
7373
// in case of multiple prefix operators (!!(a == b), for example.)
7474
var condition = condition
7575
do {
76-
var expression: Expression? = expression
76+
var expression: __Expression? = expression
7777
while case let .negation(subexpression, _) = expression?.kind {
7878
defer {
7979
expression = subexpression
@@ -163,7 +163,7 @@ private func _callBinaryOperator<T, U, R>(
163163
/// `#require()` macros. Do not call it directly.
164164
public func __checkBinaryOperation<T, U>(
165165
_ lhs: T, _ op: (T, () -> U) -> Bool, _ rhs: @autoclosure () -> U,
166-
expression: Expression,
166+
expression: __Expression,
167167
comments: @autoclosure () -> [Comment],
168168
isRequired: Bool,
169169
sourceLocation: SourceLocation
@@ -194,7 +194,7 @@ public func __checkBinaryOperation<T, U>(
194194
/// `#require()` macros. Do not call it directly.
195195
public func __checkFunctionCall<T, each U>(
196196
_ lhs: T, calling functionCall: (T, repeat each U) throws -> Bool, _ arguments: repeat each U,
197-
expression: Expression,
197+
expression: __Expression,
198198
comments: @autoclosure () -> [Comment],
199199
isRequired: Bool,
200200
sourceLocation: SourceLocation
@@ -222,7 +222,7 @@ public func __checkFunctionCall<T, each U>(
222222
/// `#require()` macros. Do not call it directly.
223223
public func __checkFunctionCall<T, Arg0>(
224224
_ lhs: T, calling functionCall: (T, Arg0) throws -> Bool, _ argument0: Arg0,
225-
expression: Expression,
225+
expression: __Expression,
226226
comments: @autoclosure () -> [Comment],
227227
isRequired: Bool,
228228
sourceLocation: SourceLocation
@@ -249,7 +249,7 @@ public func __checkFunctionCall<T, Arg0>(
249249
/// `#require()` macros. Do not call it directly.
250250
public func __checkFunctionCall<T, Arg0, Arg1>(
251251
_ lhs: T, calling functionCall: (T, Arg0, Arg1) throws -> Bool, _ argument0: Arg0, _ argument1: Arg1,
252-
expression: Expression,
252+
expression: __Expression,
253253
comments: @autoclosure () -> [Comment],
254254
isRequired: Bool,
255255
sourceLocation: SourceLocation
@@ -276,7 +276,7 @@ public func __checkFunctionCall<T, Arg0, Arg1>(
276276
/// `#require()` macros. Do not call it directly.
277277
public func __checkFunctionCall<T, Arg0, Arg1, Arg2>(
278278
_ lhs: T, calling functionCall: (T, Arg0, Arg1, Arg2) throws -> Bool, _ argument0: Arg0, _ argument1: Arg1, _ argument2: Arg2,
279-
expression: Expression,
279+
expression: __Expression,
280280
comments: @autoclosure () -> [Comment],
281281
isRequired: Bool,
282282
sourceLocation: SourceLocation
@@ -303,7 +303,7 @@ public func __checkFunctionCall<T, Arg0, Arg1, Arg2>(
303303
/// `#require()` macros. Do not call it directly.
304304
public func __checkFunctionCall<T, Arg0, Arg1, Arg2, Arg3>(
305305
_ lhs: T, calling functionCall: (T, Arg0, Arg1, Arg2, Arg3) throws -> Bool, _ argument0: Arg0, _ argument1: Arg1, _ argument2: Arg2, _ argument3: Arg3,
306-
expression: Expression,
306+
expression: __Expression,
307307
comments: @autoclosure () -> [Comment],
308308
isRequired: Bool,
309309
sourceLocation: SourceLocation
@@ -333,7 +333,7 @@ public func __checkFunctionCall<T, Arg0, Arg1, Arg2, Arg3>(
333333
/// `#require()` macros. Do not call it directly.
334334
public func __checkInoutFunctionCall<T, /*each*/ U>(
335335
_ lhs: T, calling functionCall: (T, inout /*repeat each*/ U) throws -> Bool, _ arguments: inout /*repeat each*/ U,
336-
expression: Expression,
336+
expression: __Expression,
337337
comments: @autoclosure () -> [Comment],
338338
isRequired: Bool,
339339
sourceLocation: SourceLocation
@@ -363,7 +363,7 @@ public func __checkInoutFunctionCall<T, /*each*/ U>(
363363
/// `#require()` macros. Do not call it directly.
364364
public func __checkFunctionCall<T, each U, R>(
365365
_ lhs: T, calling functionCall: (T, repeat each U) throws -> R?, _ arguments: repeat each U,
366-
expression: Expression,
366+
expression: __Expression,
367367
comments: @autoclosure () -> [Comment],
368368
isRequired: Bool,
369369
sourceLocation: SourceLocation
@@ -391,7 +391,7 @@ public func __checkFunctionCall<T, each U, R>(
391391
/// `#require()` macros. Do not call it directly.
392392
public func __checkFunctionCall<T, Arg0, R>(
393393
_ lhs: T, calling functionCall: (T, Arg0) throws -> R?, _ argument0: Arg0,
394-
expression: Expression,
394+
expression: __Expression,
395395
comments: @autoclosure () -> [Comment],
396396
isRequired: Bool,
397397
sourceLocation: SourceLocation
@@ -418,7 +418,7 @@ public func __checkFunctionCall<T, Arg0, R>(
418418
/// `#require()` macros. Do not call it directly.
419419
public func __checkFunctionCall<T, Arg0, Arg1, R>(
420420
_ lhs: T, calling functionCall: (T, Arg0, Arg1) throws -> R?, _ argument0: Arg0, _ argument1: Arg1,
421-
expression: Expression,
421+
expression: __Expression,
422422
comments: @autoclosure () -> [Comment],
423423
isRequired: Bool,
424424
sourceLocation: SourceLocation
@@ -445,7 +445,7 @@ public func __checkFunctionCall<T, Arg0, Arg1, R>(
445445
/// `#require()` macros. Do not call it directly.
446446
public func __checkFunctionCall<T, Arg0, Arg1, Arg2, R>(
447447
_ lhs: T, calling functionCall: (T, Arg0, Arg1, Arg2) throws -> R?, _ argument0: Arg0, _ argument1: Arg1, _ argument2: Arg2,
448-
expression: Expression,
448+
expression: __Expression,
449449
comments: @autoclosure () -> [Comment],
450450
isRequired: Bool,
451451
sourceLocation: SourceLocation
@@ -472,7 +472,7 @@ public func __checkFunctionCall<T, Arg0, Arg1, Arg2, R>(
472472
/// `#require()` macros. Do not call it directly.
473473
public func __checkFunctionCall<T, Arg0, Arg1, Arg2, Arg3, R>(
474474
_ lhs: T, calling functionCall: (T, Arg0, Arg1, Arg2, Arg3) throws -> R?, _ argument0: Arg0, _ argument1: Arg1, _ argument2: Arg2, _ argument3: Arg3,
475-
expression: Expression,
475+
expression: __Expression,
476476
comments: @autoclosure () -> [Comment],
477477
isRequired: Bool,
478478
sourceLocation: SourceLocation
@@ -503,7 +503,7 @@ public func __checkFunctionCall<T, Arg0, Arg1, Arg2, Arg3, R>(
503503
/// `#require()` macros. Do not call it directly.
504504
public func __checkInoutFunctionCall<T, /*each*/ U, R>(
505505
_ lhs: T, calling functionCall: (T, inout /*repeat each*/ U) throws -> R?, _ arguments: inout /*repeat each*/ U,
506-
expression: Expression,
506+
expression: __Expression,
507507
comments: @autoclosure () -> [Comment],
508508
isRequired: Bool,
509509
sourceLocation: SourceLocation
@@ -534,7 +534,7 @@ public func __checkInoutFunctionCall<T, /*each*/ U, R>(
534534
/// `#require()` macros. Do not call it directly.
535535
public func __checkPropertyAccess<T>(
536536
_ lhs: T, getting memberAccess: (T) -> Bool,
537-
expression: Expression,
537+
expression: __Expression,
538538
comments: @autoclosure () -> [Comment],
539539
isRequired: Bool,
540540
sourceLocation: SourceLocation
@@ -564,7 +564,7 @@ public func __checkPropertyAccess<T>(
564564
/// `#require()` macros. Do not call it directly.
565565
public func __checkPropertyAccess<T, U>(
566566
_ lhs: T, getting memberAccess: (T) -> U?,
567-
expression: Expression,
567+
expression: __Expression,
568568
comments: @autoclosure () -> [Comment],
569569
isRequired: Bool,
570570
sourceLocation: SourceLocation
@@ -592,7 +592,7 @@ public func __checkPropertyAccess<T, U>(
592592
/// `#require()` macros. Do not call it directly.
593593
public func __checkBinaryOperation<T>(
594594
_ lhs: T, _ op: (T, () -> T) -> Bool, _ rhs: @autoclosure () -> T,
595-
expression: Expression,
595+
expression: __Expression,
596596
comments: @autoclosure () -> [Comment],
597597
isRequired: Bool,
598598
sourceLocation: SourceLocation
@@ -639,7 +639,7 @@ public func __checkBinaryOperation<T>(
639639
/// `#require()` macros. Do not call it directly.
640640
public func __checkBinaryOperation(
641641
_ lhs: String, _ op: (String, () -> String) -> Bool, _ rhs: @autoclosure () -> String,
642-
expression: Expression,
642+
expression: __Expression,
643643
comments: @autoclosure () -> [Comment],
644644
isRequired: Bool,
645645
sourceLocation: SourceLocation
@@ -666,7 +666,7 @@ public func __checkBinaryOperation(
666666
public func __checkCast<V, T>(
667667
_ value: V,
668668
is _: T.Type,
669-
expression: Expression,
669+
expression: __Expression,
670670
comments: @autoclosure () -> [Comment],
671671
isRequired: Bool,
672672
sourceLocation: SourceLocation
@@ -698,8 +698,8 @@ public func __checkCast<V, T>(
698698
/// `#require()` macros. Do not call it directly.
699699
public func __checkValue<T>(
700700
_ optionalValue: T?,
701-
expression: Expression,
702-
expressionWithCapturedRuntimeValues: @autoclosure () -> Expression? = nil,
701+
expression: __Expression,
702+
expressionWithCapturedRuntimeValues: @autoclosure () -> __Expression? = nil,
703703
comments: @autoclosure () -> [Comment],
704704
isRequired: Bool,
705705
sourceLocation: SourceLocation
@@ -738,7 +738,7 @@ public func __checkValue<T>(
738738
/// `#require()` macros. Do not call it directly.
739739
public func __checkBinaryOperation<T>(
740740
_ lhs: T?, _ op: (T?, () -> T?) -> T?, _ rhs: @autoclosure () -> T?,
741-
expression: Expression,
741+
expression: __Expression,
742742
comments: @autoclosure () -> [Comment],
743743
isRequired: Bool,
744744
sourceLocation: SourceLocation
@@ -764,7 +764,7 @@ public func __checkBinaryOperation<T>(
764764
public func __checkCast<V, T>(
765765
_ value: V,
766766
as _: T.Type,
767-
expression: Expression,
767+
expression: __Expression,
768768
comments: @autoclosure () -> [Comment],
769769
isRequired: Bool,
770770
sourceLocation: SourceLocation
@@ -797,7 +797,7 @@ public func __checkCast<V, T>(
797797
public func __checkClosureCall<E>(
798798
throws errorType: E.Type,
799799
performing body: () throws -> some Any,
800-
expression: Expression,
800+
expression: __Expression,
801801
comments: @autoclosure () -> [Comment],
802802
isRequired: Bool,
803803
sourceLocation: SourceLocation
@@ -834,7 +834,7 @@ public func __checkClosureCall<E>(
834834
public func __checkClosureCall<E>(
835835
throws errorType: E.Type,
836836
performing body: () async throws -> some Any,
837-
expression: Expression,
837+
expression: __Expression,
838838
comments: @autoclosure () -> [Comment],
839839
isRequired: Bool,
840840
sourceLocation: SourceLocation
@@ -874,7 +874,7 @@ public func __checkClosureCall<E>(
874874
public func __checkClosureCall(
875875
throws _: Never.Type,
876876
performing body: () throws -> some Any,
877-
expression: Expression,
877+
expression: __Expression,
878878
comments: @autoclosure () -> [Comment],
879879
isRequired: Bool,
880880
sourceLocation: SourceLocation
@@ -910,7 +910,7 @@ public func __checkClosureCall(
910910
public func __checkClosureCall(
911911
throws _: Never.Type,
912912
performing body: () async throws -> some Any,
913-
expression: Expression,
913+
expression: __Expression,
914914
comments: @autoclosure () -> [Comment],
915915
isRequired: Bool,
916916
sourceLocation: SourceLocation
@@ -946,7 +946,7 @@ public func __checkClosureCall(
946946
public func __checkClosureCall<E>(
947947
throws error: E,
948948
performing body: () throws -> some Any,
949-
expression: Expression,
949+
expression: __Expression,
950950
comments: @autoclosure () -> [Comment],
951951
isRequired: Bool,
952952
sourceLocation: SourceLocation
@@ -972,7 +972,7 @@ public func __checkClosureCall<E>(
972972
public func __checkClosureCall<E>(
973973
throws error: E,
974974
performing body: () async throws -> some Any,
975-
expression: Expression,
975+
expression: __Expression,
976976
comments: @autoclosure () -> [Comment],
977977
isRequired: Bool,
978978
sourceLocation: SourceLocation
@@ -1000,7 +1000,7 @@ public func __checkClosureCall<R>(
10001000
performing body: () throws -> R,
10011001
throws errorMatcher: (any Error) throws -> Bool,
10021002
mismatchExplanation: ((any Error) -> String)? = nil,
1003-
expression: Expression,
1003+
expression: __Expression,
10041004
comments: @autoclosure () -> [Comment],
10051005
isRequired: Bool,
10061006
sourceLocation: SourceLocation
@@ -1048,7 +1048,7 @@ public func __checkClosureCall<R>(
10481048
performing body: () async throws -> R,
10491049
throws errorMatcher: (any Error) async throws -> Bool,
10501050
mismatchExplanation: ((any Error) -> String)? = nil,
1051-
expression: Expression,
1051+
expression: __Expression,
10521052
comments: @autoclosure () -> [Comment],
10531053
isRequired: Bool,
10541054
sourceLocation: SourceLocation
@@ -1102,7 +1102,7 @@ public func __checkClosureCall<R>(
11021102
public func __checkClosureCall(
11031103
exitsWith expectedExitCondition: ExitCondition,
11041104
performing body: @convention(thin) () async -> Void,
1105-
expression: Expression,
1105+
expression: __Expression,
11061106
comments: @autoclosure () -> [Comment],
11071107
isRequired: Bool,
11081108
sourceLocation: SourceLocation

Sources/Testing/Parameterization/Test.Case.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ extension Test.Case.Argument {
198198

199199
/// A representation of this parameterized test argument's
200200
/// ``Test/Case/Argument/value`` property.
201-
@_spi(ForToolsIntegrationOnly)
202201
public var value: Expression.Value
203202

204203
/// The parameter of the test function to which this argument was passed.

0 commit comments

Comments
 (0)