Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ extension Test.Case {
arguments collection: S,
parameters: [Test.Parameter],
testFunction: @escaping @Sendable ((S.Key, S.Value)) async throws -> Void
) where S: __DictionaryLikeCollection {
) where S: ExpressibleByDictionaryLiteral, S.Element == (key: S.Key, value: S.Value) {
if parameters.count > 1 {
self.init(sequence: collection) { element in
Test.Case(values: [element.key, element.value], parameters: parameters) {
Expand Down
17 changes: 1 addition & 16 deletions Sources/Testing/Test+Macro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ extension Test {
sourceBounds: __SourceBounds,
parameters paramTuples: [__Parameter],
testFunction: @escaping @Sendable (C.Element) async throws -> Void
) -> Self where S: ~Copyable & ~Escapable, C: __DictionaryLikeCollection & Sendable, C.Key: Sendable, C.Value: Sendable {
) -> Self where S: ~Copyable & ~Escapable, C: ExpressibleByDictionaryLiteral & Collection & Sendable, C.Element == (key: C.Key, value: C.Value), C.Key: Sendable, C.Value: Sendable {
let containingTypeInfo: TypeInfo? = if let containingType {
TypeInfo(describing: containingType)
} else {
Expand Down Expand Up @@ -529,21 +529,6 @@ extension Test {
warning message: _const String
) = #externalMacro(module: "TestingMacros", type: "PragmaMacro")

// MARK: - Dictionary-like collection disambiguation

/// A protocol that describes the basic shape of a "dictionary-like" collection
/// whose elements are key-value pairs.
///
/// - Warning: This protocol is used to implement the `@Test` macro. Do not use
/// it directly.
public protocol __DictionaryLikeCollection<Key, Value>: Collection where Element == (key: Key, value: Value) {
associatedtype Key
associatedtype Value
}

extension Dictionary: __DictionaryLikeCollection {}
extension KeyValuePairs: __DictionaryLikeCollection {}

// MARK: - Helper functions

/// A function that abstracts away whether or not the `try` keyword is needed on
Expand Down
Loading