File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 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 {
144144 // exit test handler or entry point is likely broken.
145145 guard let wrappedValue = capturedValues. first? . wrappedValue else {
146146 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)
154148 fatalError ( " Found fewer captured values ( \( actualCount) ) than expected ( \( expectedCount) ) when passing them to the current exit test. " )
155149 }
156150
Original file line number Diff line number Diff line change @@ -21,3 +21,21 @@ extension Array {
2121 self = optionalValue. map { [ $0] } ?? [ ]
2222 }
2323}
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