File tree 2 files changed +19
-7
lines changed
2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -144,13 +144,7 @@ extension Collection where Element == ExitTest.CapturedValue {
144
144
// exit test handler or entry point is likely broken.
145
145
guard let wrappedValue = capturedValues. first? . wrappedValue else {
146
146
let actualCount = self . count
147
- let expectedCount : Int = {
148
- var result = 0
149
- for _ in repeat ( each T) . self {
150
- result += 1
151
- }
152
- return result
153
- } ( )
147
+ let expectedCount = parameterPackCount ( repeat ( each T) . self)
154
148
fatalError ( " Found fewer captured values ( \( actualCount) ) than expected ( \( expectedCount) ) when passing them to the current exit test. " )
155
149
}
156
150
Original file line number Diff line number Diff line change @@ -21,3 +21,21 @@ extension Array {
21
21
self = optionalValue. map { [ $0] } ?? [ ]
22
22
}
23
23
}
24
+
25
+ /// Get the number of elements in a parameter pack.
26
+ ///
27
+ /// - Parameters:
28
+ /// - pack: The parameter pack.
29
+ ///
30
+ /// - Returns: The number of elements in `pack`.
31
+ ///
32
+ /// - Complexity: O(_n_) where _n_ is the number of elements in `pack`. The
33
+ /// compiler may be able to optimize this operation when the types of `pack`
34
+ /// are statically known.
35
+ func parameterPackCount< each T > ( _ pack: repeat each T ) -> Int {
36
+ var result = 0
37
+ for _ in repeat each pack {
38
+ result += 1
39
+ }
40
+ return result
41
+ }
You can’t perform that action at this time.
0 commit comments