Skip to content

Commit e15e85b

Browse files
committed
Update callCount and thrownErrors to use checked locks
1 parent 68c4ead commit e15e85b

File tree

21 files changed

+75
-75
lines changed

21 files changed

+75
-75
lines changed

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningNonParameterizedAsyncMethod/MockReturningNonParameterizedAsyncMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class MockReturningNonParameterizedAsyncMethod<ReturnValue> {
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
/// All the values that have been returned by the method.
@@ -103,7 +103,7 @@ public final class MockReturningNonParameterizedAsyncMethod<ReturnValue> {
103103
/// - Returns: A value, if ``implementation-swift.property`` returns a
104104
/// value.
105105
private func invoke() async -> ReturnValue {
106-
self._callCount.withLockUnchecked { callCount in
106+
self._callCount.withLock { callCount in
107107
callCount += 1
108108
}
109109

@@ -125,7 +125,7 @@ public final class MockReturningNonParameterizedAsyncMethod<ReturnValue> {
125125
self._implementation.withLockUnchecked { implementation in
126126
implementation = .unimplemented
127127
}
128-
self._callCount.withLockUnchecked { callCount in
128+
self._callCount.withLock { callCount in
129129
callCount = .zero
130130
}
131131
self._returnedValues.withLockUnchecked { returnedValues in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningNonParameterizedAsyncThrowingMethod/MockReturningNonParameterizedAsyncThrowingMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class MockReturningNonParameterizedAsyncThrowingMethod<ReturnValue>
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
/// All the values that have been returned by the method.
@@ -105,7 +105,7 @@ public final class MockReturningNonParameterizedAsyncThrowingMethod<ReturnValue>
105105
/// - Returns: A value, if ``implementation-swift.property`` returns a
106106
/// value.
107107
private func invoke() async throws -> ReturnValue {
108-
self._callCount.withLockUnchecked { callCount in
108+
self._callCount.withLock { callCount in
109109
callCount += 1
110110
}
111111

@@ -131,7 +131,7 @@ public final class MockReturningNonParameterizedAsyncThrowingMethod<ReturnValue>
131131
self._implementation.withLockUnchecked { implementation in
132132
implementation = .unimplemented
133133
}
134-
self._callCount.withLockUnchecked { callCount in
134+
self._callCount.withLock { callCount in
135135
callCount = .zero
136136
}
137137
self._returnedValues.withLockUnchecked { returnedValues in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningNonParameterizedMethod/MockReturningNonParameterizedMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class MockReturningNonParameterizedMethod<ReturnValue> {
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
/// All the values that have been returned by the method.
@@ -101,7 +101,7 @@ public final class MockReturningNonParameterizedMethod<ReturnValue> {
101101
/// - Returns: A value, if ``implementation-swift.property`` returns a
102102
/// value.
103103
private func invoke() -> ReturnValue {
104-
self._callCount.withLockUnchecked { callCount in
104+
self._callCount.withLock { callCount in
105105
callCount += 1
106106
}
107107

@@ -123,7 +123,7 @@ public final class MockReturningNonParameterizedMethod<ReturnValue> {
123123
self._implementation.withLockUnchecked { implementation in
124124
implementation = .unimplemented
125125
}
126-
self._callCount.withLockUnchecked { callCount in
126+
self._callCount.withLock { callCount in
127127
callCount = .zero
128128
}
129129
self._returnedValues.withLockUnchecked { returnedValues in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningNonParameterizedThrowingMethod/MockReturningNonParameterizedThrowingMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class MockReturningNonParameterizedThrowingMethod<ReturnValue> {
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
/// All the values that have been returned by the method.
@@ -105,7 +105,7 @@ public final class MockReturningNonParameterizedThrowingMethod<ReturnValue> {
105105
/// - Returns: A value, if ``implementation-swift.property`` returns a
106106
/// value.
107107
private func invoke() throws -> ReturnValue {
108-
self._callCount.withLockUnchecked { callCount in
108+
self._callCount.withLock { callCount in
109109
callCount += 1
110110
}
111111

@@ -131,7 +131,7 @@ public final class MockReturningNonParameterizedThrowingMethod<ReturnValue> {
131131
self._implementation.withLockUnchecked { implementation in
132132
implementation = .unimplemented
133133
}
134-
self._callCount.withLockUnchecked { callCount in
134+
self._callCount.withLock { callCount in
135135
callCount = .zero
136136
}
137137
self._returnedValues.withLockUnchecked { returnedValues in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningParameterizedAsyncMethod/MockReturningParameterizedAsyncMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class MockReturningParameterizedAsyncMethod<
3131
public var implementation: Implementation = .unimplemented
3232

3333
/// The number of times the method has been called.
34-
@Locked(.unchecked)
34+
@Locked(.checked)
3535
public private(set) var callCount: Int = .zero
3636

3737
/// All the arguments with which the method has been invoked.
@@ -140,7 +140,7 @@ public final class MockReturningParameterizedAsyncMethod<
140140
/// - Parameter arguments: The arguments with which the method is being
141141
/// invoked.
142142
private func recordInput(arguments: Arguments) {
143-
self._callCount.withLockUnchecked { callCount in
143+
self._callCount.withLock { callCount in
144144
callCount += 1
145145
}
146146
self._invocations.withLockUnchecked { invocations in
@@ -176,7 +176,7 @@ public final class MockReturningParameterizedAsyncMethod<
176176
self._implementation.withLockUnchecked { implementation in
177177
implementation = .unimplemented
178178
}
179-
self._callCount.withLockUnchecked { callCount in
179+
self._callCount.withLock { callCount in
180180
callCount = .zero
181181
}
182182
self._invocations.withLockUnchecked { invocations in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningParameterizedAsyncThrowingMethod/MockReturningParameterizedAsyncThrowingMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class MockReturningParameterizedAsyncThrowingMethod<
3434
public var implementation: Implementation = .unimplemented
3535

3636
/// The number of times the method has been called.
37-
@Locked(.unchecked)
37+
@Locked(.checked)
3838
public private(set) var callCount: Int = .zero
3939

4040
/// All the arguments with which the method has been invoked.
@@ -148,7 +148,7 @@ public final class MockReturningParameterizedAsyncThrowingMethod<
148148
/// - Parameter arguments: The arguments with which the method is being
149149
/// invoked.
150150
private func recordInput(arguments: Arguments) {
151-
self._callCount.withLockUnchecked { callCount in
151+
self._callCount.withLock { callCount in
152152
callCount += 1
153153
}
154154
self._invocations.withLockUnchecked { invocations in
@@ -184,7 +184,7 @@ public final class MockReturningParameterizedAsyncThrowingMethod<
184184
self._implementation.withLockUnchecked { implementation in
185185
implementation = .unimplemented
186186
}
187-
self._callCount.withLockUnchecked { callCount in
187+
self._callCount.withLock { callCount in
188188
callCount = .zero
189189
}
190190
self._invocations.withLockUnchecked { invocations in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningParameterizedMethod/MockReturningParameterizedMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class MockReturningParameterizedMethod<
3131
public var implementation: Implementation = .unimplemented
3232

3333
/// The number of times the method has been called.
34-
@Locked(.unchecked)
34+
@Locked(.checked)
3535
public private(set) var callCount: Int = .zero
3636

3737
/// All the arguments with which the method has been invoked.
@@ -140,7 +140,7 @@ public final class MockReturningParameterizedMethod<
140140
/// - Parameter arguments: The arguments with which the method is being
141141
/// invoked.
142142
private func recordInput(arguments: Arguments) {
143-
self._callCount.withLockUnchecked { callCount in
143+
self._callCount.withLock { callCount in
144144
callCount += 1
145145
}
146146
self._invocations.withLockUnchecked { invocations in
@@ -176,7 +176,7 @@ public final class MockReturningParameterizedMethod<
176176
self._implementation.withLockUnchecked { implementation in
177177
implementation = .unimplemented
178178
}
179-
self._callCount.withLockUnchecked { callCount in
179+
self._callCount.withLock { callCount in
180180
callCount = .zero
181181
}
182182
self._invocations.withLockUnchecked { invocations in

Sources/Mocking/Models/MockMethods/MockReturningMethods/MockReturningParameterizedThrowingMethod/MockReturningParameterizedThrowingMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class MockReturningParameterizedThrowingMethod<
3434
public var implementation: Implementation = .unimplemented
3535

3636
/// The number of times the method has been called.
37-
@Locked(.unchecked)
37+
@Locked(.checked)
3838
public private(set) var callCount: Int = .zero
3939

4040
/// All the arguments with which the method has been invoked.
@@ -147,7 +147,7 @@ public final class MockReturningParameterizedThrowingMethod<
147147
/// - Parameter arguments: The arguments with which the method is being
148148
/// invoked.
149149
private func recordInput(arguments: Arguments) {
150-
self._callCount.withLockUnchecked { callCount in
150+
self._callCount.withLock { callCount in
151151
callCount += 1
152152
}
153153
self._invocations.withLockUnchecked { invocations in
@@ -183,7 +183,7 @@ public final class MockReturningParameterizedThrowingMethod<
183183
self._implementation.withLockUnchecked { implementation in
184184
implementation = .unimplemented
185185
}
186-
self._callCount.withLockUnchecked { callCount in
186+
self._callCount.withLock { callCount in
187187
callCount = .zero
188188
}
189189
self._invocations.withLockUnchecked { invocations in

Sources/Mocking/Models/MockMethods/MockVoidMethods/MockVoidNonParameterizedAsyncMethod/MockVoidNonParameterizedAsyncMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class MockVoidNonParameterizedAsyncMethod: Sendable {
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
// MARK: Initializers
@@ -68,7 +68,7 @@ public final class MockVoidNonParameterizedAsyncMethod: Sendable {
6868
/// Records the invocation of the method and invokes
6969
/// ``implementation-swift.property``.
7070
private func invoke() async {
71-
self._callCount.withLockUnchecked { callCount in
71+
self._callCount.withLock { callCount in
7272
callCount += 1
7373
}
7474
await self.implementation()
@@ -81,7 +81,7 @@ public final class MockVoidNonParameterizedAsyncMethod: Sendable {
8181
self._implementation.withLockUnchecked { implementation in
8282
implementation = .unimplemented
8383
}
84-
self._callCount.withLockUnchecked { callCount in
84+
self._callCount.withLock { callCount in
8585
callCount = .zero
8686
}
8787
}

Sources/Mocking/Models/MockMethods/MockVoidMethods/MockVoidNonParameterizedAsyncThrowingMethod/MockVoidNonParameterizedAsyncThrowingMethod.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public final class MockVoidNonParameterizedAsyncThrowingMethod: Sendable {
1818
public var implementation: Implementation = .unimplemented
1919

2020
/// The number of times the method has been called.
21-
@Locked(.unchecked)
21+
@Locked(.checked)
2222
public private(set) var callCount: Int = .zero
2323

2424
/// All the errors that have been thrown by the method.
25-
@Locked(.unchecked)
25+
@Locked(.checked)
2626
public private(set) var thrownErrors: [any Error] = []
2727

2828
/// The last error thrown by the method.
@@ -78,14 +78,14 @@ public final class MockVoidNonParameterizedAsyncThrowingMethod: Sendable {
7878
/// Records the invocation of the method and invokes
7979
/// ``implementation-swift.property``.
8080
private func invoke() async throws {
81-
self._callCount.withLockUnchecked { callCount in
81+
self._callCount.withLock { callCount in
8282
callCount += 1
8383
}
8484

8585
do {
8686
try await self.implementation()
8787
} catch {
88-
self._thrownErrors.withLockUnchecked { thrownErrors in
88+
self._thrownErrors.withLock { thrownErrors in
8989
thrownErrors.append(error)
9090
}
9191
throw error
@@ -99,10 +99,10 @@ public final class MockVoidNonParameterizedAsyncThrowingMethod: Sendable {
9999
self._implementation.withLockUnchecked { implementation in
100100
implementation = .unimplemented
101101
}
102-
self._callCount.withLockUnchecked { callCount in
102+
self._callCount.withLock { callCount in
103103
callCount = .zero
104104
}
105-
self._thrownErrors.withLockUnchecked { thrownErrors in
105+
self._thrownErrors.withLock { thrownErrors in
106106
thrownErrors.removeAll()
107107
}
108108
}

0 commit comments

Comments
 (0)