-
Notifications
You must be signed in to change notification settings - Fork 126
Closed as not planned
Labels
enhancementNew feature or requestNew feature or requestwontfix❌ This will not be worked on❌ This will not be worked on
Description
Description
We have some generic interface in the codebase. And I'd request generic function support for @Test macro.
The following is a simplified version of my use case.
protocol Key {
associated Value
static var defaultValue: Value
static func reduce(value: inout Value, nextValue: () -> Value)
}
struct AddIntKey: Key {
static var defaultValue: Int { 0 }
static func reduce(value: inout Int, nextValue: () -> Int) {
value += nextValue()
}
}
struct MultipleIntKey: Key {
static var defaultValue: Int { 0 }
static func reduce(value: inout Int, nextValue: () -> Int) {
value *= nextValue()
}
}Expected behavior
@Test(arguments: [ // ✅
(AddIntKey.self, [1, 2], 3)
(MultipleIntKey.self, [1, 2], 2)
])
func reduce<Key: PreferenceKey>(
type: Key.Type, values: [Key.Value], expectedValues: Key.Value
) {
...
}Actual behavior
@Test(arguments: [ // ❌: The @Test attribute cannot be applied to a generic function.
(AddIntKey.self, [1, 2], 3)
(MultipleIntKey.self, [1, 2], 2)
])
func reduce<Key: PreferenceKey>(
type: Key.Type, values: [Key.Value], expectedValues: Key.Value
) {
...
}Steps to reproduce
No response
swift-testing version/commit hash
No response
Swift & OS version (output of swift --version && uname -a)
No response
JessyCatterwaul
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestwontfix❌ This will not be worked on❌ This will not be worked on