From 956861afe57073a61318eac553da59310ab23e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kolos=20Folta=CC=81nyi?= Date: Mon, 24 Jun 2024 15:11:34 +0200 Subject: [PATCH] fix: support sendable conformance --- Sources/Mockable/Mocker/Mocker.swift | 2 +- Sources/MockableMacro/Factory/MemberFactory.swift | 2 +- Tests/MockableMacroTests/AccessModifierTests.swift | 2 +- Tests/MockableMacroTests/AssociatedTypeTests.swift | 6 +++--- Tests/MockableMacroTests/AttributesTests.swift | 2 +- Tests/MockableMacroTests/ExoticParameterTests.swift | 6 +++--- Tests/MockableMacroTests/FunctionEffectTests.swift | 6 +++--- Tests/MockableMacroTests/GenericFunctionTests.swift | 6 +++--- Tests/MockableMacroTests/InitRequirementTests.swift | 4 ++-- Tests/MockableMacroTests/NameCollisionTests.swift | 6 +++--- Tests/MockableMacroTests/PropertyRequirementTests.swift | 6 +++--- Tests/MockableTests/Protocols/TestProtocol.swift | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Sources/Mockable/Mocker/Mocker.swift b/Sources/Mockable/Mocker/Mocker.swift index 84528607..77cfc653 100644 --- a/Sources/Mockable/Mocker/Mocker.swift +++ b/Sources/Mockable/Mocker/Mocker.swift @@ -12,7 +12,7 @@ import Combine /// /// The `Mocker` class keeps track of invocations, expected return values, and actions associated with /// specific members of a mockable service. -public class Mocker { +public class Mocker: @unchecked Sendable { // MARK: Public Properties diff --git a/Sources/MockableMacro/Factory/MemberFactory.swift b/Sources/MockableMacro/Factory/MemberFactory.swift index b8f5775b..fb3337f2 100644 --- a/Sources/MockableMacro/Factory/MemberFactory.swift +++ b/Sources/MockableMacro/Factory/MemberFactory.swift @@ -38,7 +38,7 @@ extension MemberFactory { private static func mocker(_ requirements: Requirements) -> VariableDeclSyntax { VariableDeclSyntax( modifiers: [DeclModifierSyntax(name: .keyword(.private))], - bindingSpecifier: .keyword(.var) + bindingSpecifier: .keyword(.let) ) { PatternBindingSyntax( pattern: IdentifierPatternSyntax(identifier: NS.mocker), diff --git a/Tests/MockableMacroTests/AccessModifierTests.swift b/Tests/MockableMacroTests/AccessModifierTests.swift index e9096a60..9a7eb291 100644 --- a/Tests/MockableMacroTests/AccessModifierTests.swift +++ b/Tests/MockableMacroTests/AccessModifierTests.swift @@ -29,7 +29,7 @@ final class AccessModifierTests: MockableMacroTestCase { #if MOCKING private final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/AssociatedTypeTests.swift b/Tests/MockableMacroTests/AssociatedTypeTests.swift index bb9d6c63..0b8d333f 100644 --- a/Tests/MockableMacroTests/AssociatedTypeTests.swift +++ b/Tests/MockableMacroTests/AssociatedTypeTests.swift @@ -27,7 +27,7 @@ final class AssociatedTypeTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -117,7 +117,7 @@ final class AssociatedTypeTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService where Item: Equatable, Item: Hashable { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -207,7 +207,7 @@ final class AssociatedTypeTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService where Item: Equatable, Item: Hashable { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/AttributesTests.swift b/Tests/MockableMacroTests/AttributesTests.swift index 3f58fc26..9044f28a 100644 --- a/Tests/MockableMacroTests/AttributesTests.swift +++ b/Tests/MockableMacroTests/AttributesTests.swift @@ -51,7 +51,7 @@ final class AttributesTests: MockableMacroTestCase { #if MOCKING final class MockAttributeTest: AttributeTest, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/ExoticParameterTests.swift b/Tests/MockableMacroTests/ExoticParameterTests.swift index 1be41375..6cd309d5 100644 --- a/Tests/MockableMacroTests/ExoticParameterTests.swift +++ b/Tests/MockableMacroTests/ExoticParameterTests.swift @@ -25,7 +25,7 @@ final class ExoticParameterTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -113,7 +113,7 @@ final class ExoticParameterTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -201,7 +201,7 @@ final class ExoticParameterTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/FunctionEffectTests.swift b/Tests/MockableMacroTests/FunctionEffectTests.swift index a076ff98..c3f3940e 100644 --- a/Tests/MockableMacroTests/FunctionEffectTests.swift +++ b/Tests/MockableMacroTests/FunctionEffectTests.swift @@ -28,7 +28,7 @@ final class FunctionEffectTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -137,7 +137,7 @@ final class FunctionEffectTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -229,7 +229,7 @@ final class FunctionEffectTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/GenericFunctionTests.swift b/Tests/MockableMacroTests/GenericFunctionTests.swift index 14a81f2d..de3623ef 100644 --- a/Tests/MockableMacroTests/GenericFunctionTests.swift +++ b/Tests/MockableMacroTests/GenericFunctionTests.swift @@ -25,7 +25,7 @@ final class GenericFunctionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -113,7 +113,7 @@ final class GenericFunctionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -205,7 +205,7 @@ final class GenericFunctionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/InitRequirementTests.swift b/Tests/MockableMacroTests/InitRequirementTests.swift index d5e39e66..60f29a38 100644 --- a/Tests/MockableMacroTests/InitRequirementTests.swift +++ b/Tests/MockableMacroTests/InitRequirementTests.swift @@ -27,7 +27,7 @@ final class InitRequirementTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -104,7 +104,7 @@ final class InitRequirementTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/NameCollisionTests.swift b/Tests/MockableMacroTests/NameCollisionTests.swift index 7e7b3281..993e9588 100644 --- a/Tests/MockableMacroTests/NameCollisionTests.swift +++ b/Tests/MockableMacroTests/NameCollisionTests.swift @@ -27,7 +27,7 @@ final class NameCollisionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -138,7 +138,7 @@ final class NameCollisionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -247,7 +247,7 @@ final class NameCollisionTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableMacroTests/PropertyRequirementTests.swift b/Tests/MockableMacroTests/PropertyRequirementTests.swift index cb67b6d2..d248e257 100644 --- a/Tests/MockableMacroTests/PropertyRequirementTests.swift +++ b/Tests/MockableMacroTests/PropertyRequirementTests.swift @@ -27,7 +27,7 @@ final class PropertyRequirementTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -142,7 +142,7 @@ final class PropertyRequirementTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) @@ -275,7 +275,7 @@ final class PropertyRequirementTests: MockableMacroTestCase { #if MOCKING final class MockTest: Test, MockableService { - private var mocker = Mocker() + private let mocker = Mocker() @available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ") func given() -> ReturnBuilder { .init(mocker: mocker) diff --git a/Tests/MockableTests/Protocols/TestProtocol.swift b/Tests/MockableTests/Protocols/TestProtocol.swift index d09d6af0..9dd53b9e 100644 --- a/Tests/MockableTests/Protocols/TestProtocol.swift +++ b/Tests/MockableTests/Protocols/TestProtocol.swift @@ -8,7 +8,7 @@ import MockableTest @Mockable -protocol TestProtocol where Item2: Identifiable { +protocol TestProtocol: Sendable where Item2: Identifiable { // MARK: Associated Types