From bf7ba2567481e1e4d5440dc842429ff7b478b831 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Sat, 31 Oct 2026 20:28:28 -0400 Subject: [PATCH] Ensure sugared/structured arguments work with `zip()`. The current implementation of `@Test` for `Zip2Sequence` (the output of `zip(_:_:)`) has a bug that prevents it from accepting a single, un-desugared tuple argument: ```swift @Test(arguments: zip(x, y)) func f(_ xy: (T, U)) { // ERROR } ``` This PR adjusts the signature of the underlying helper function to ensure the above syntax works as intended. --- Sources/Testing/Test+Macro.swift | 4 ++-- Tests/TestingTests/ZipTests.swift | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Testing/Test+Macro.swift b/Sources/Testing/Test+Macro.swift index 1b1bb59a3..4e9a349d4 100644 --- a/Sources/Testing/Test+Macro.swift +++ b/Sources/Testing/Test+Macro.swift @@ -719,7 +719,7 @@ extension Test { arguments zippedCollections: @escaping @Sendable () async throws -> Zip2Sequence, sourceBounds: __SourceBounds, parameters paramTuples: [__Parameter], - testFunction: nonisolated(nonsending) @escaping @Sendable (C1.Element, C2.Element) async throws -> Void + testFunction: nonisolated(nonsending) @escaping @Sendable ((C1.Element, C2.Element)) async throws -> Void ) -> Self where S: ~Copyable & ~Escapable, C1: Collection & Sendable, C1.Element: Sendable, C2: Collection & Sendable, C2.Element: Sendable { let containingTypeInfo = containingType.map { TypeInfo($0, sourceBounds: sourceBounds) } let parameters = paramTuples.parameters @@ -754,7 +754,7 @@ extension Test { arguments zippedCollections: @escaping @Sendable () async throws -> Zip2Sequence, sourceBounds: __SourceBounds, parameters paramTuples: [__Parameter], - testFunction: nonisolated(nonsending) @escaping @Sendable (C1.Element, C2.Element) async throws -> Void + testFunction: nonisolated(nonsending) @escaping @Sendable ((C1.Element, C2.Element)) async throws -> Void ) -> Self where S: ~Copyable & ~Escapable, C1: Collection & Sendable, C1.Element: Sendable & CustomTestStringConvertible, C2: Collection & Sendable, C2.Element: Sendable & CustomTestStringConvertible { let containingTypeInfo = containingType.map { TypeInfo($0, sourceBounds: sourceBounds) } let parameters = paramTuples.parameters diff --git a/Tests/TestingTests/ZipTests.swift b/Tests/TestingTests/ZipTests.swift index bd767b222..76e19323b 100644 --- a/Tests/TestingTests/ZipTests.swift +++ b/Tests/TestingTests/ZipTests.swift @@ -25,4 +25,9 @@ struct ZipTests { func allElementsEqual(i: Int, j: Int) { #expect(i == j) } + + @Test("Zipped collections can be passed as a single argument", arguments: zip("abc", "def")) + func singleArgument(ij: (Character, Character)) { + #expect(ij.0 < ij.1) + } }