@@ -50,14 +50,14 @@ public class MockManager {
5050 return await callRethrowsInternal ( method, parameters: parameters, escapingParameters: escapingParameters, superclassCall: superclassCall, defaultCall: defaultCall)
5151 }
5252
53- private func callRethrowsInternal< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) throws -> OUT , defaultCall: ( ) throws -> OUT ) rethrows -> OUT {
53+ private func callRethrowsInternal< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) throws ( ERROR ) -> OUT , defaultCall: ( ) throws ( ERROR ) -> OUT ) rethrows -> OUT {
5454 let stubCall = ConcreteStubCall ( method: method, parameters: escapingParameters)
5555 queue. sync {
5656 stubCalls. append ( stubCall)
5757 unverifiedStubCallsIndexes. append ( stubCalls. count - 1 )
5858 }
5959
60- if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
60+ if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT , ERROR > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
6161
6262 guard let action = queue. sync ( execute: {
6363 return stub. actions. count > 1 ? stub. actions. removeFirst ( ) : stub. actions. first
@@ -90,14 +90,14 @@ public class MockManager {
9090 }
9191 }
9292
93- private func callRethrowsInternal< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) async throws -> OUT , defaultCall: ( ) async throws -> OUT ) async rethrows -> OUT {
93+ private func callRethrowsInternal< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) async throws ( ERROR ) -> OUT , defaultCall: ( ) async throws ( ERROR ) -> OUT ) async rethrows -> OUT {
9494 let stubCall = ConcreteStubCall ( method: method, parameters: escapingParameters)
9595 queue. sync {
9696 stubCalls. append ( stubCall)
9797 unverifiedStubCallsIndexes. append ( stubCalls. count - 1 )
9898 }
9999
100- if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
100+ if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT , ERROR > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
101101
102102 guard let action = queue. sync ( execute: {
103103 return stub. actions. count > 1 ? stub. actions. removeFirst ( ) : stub. actions. first
@@ -130,14 +130,14 @@ public class MockManager {
130130 }
131131 }
132132
133- private func callThrowsInternal< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) throws -> OUT , defaultCall: ( ) throws -> OUT ) throws -> OUT {
133+ private func callThrowsInternal< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) throws ( ERROR ) -> OUT , defaultCall: ( ) throws ( ERROR ) -> OUT ) throws ( ERROR ) -> OUT {
134134 let stubCall = ConcreteStubCall ( method: method, parameters: escapingParameters)
135135 queue. sync {
136136 stubCalls. append ( stubCall)
137137 unverifiedStubCallsIndexes. append ( stubCalls. count - 1 )
138138 }
139139
140- if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
140+ if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT , ERROR > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
141141
142142 guard let action = queue. sync ( execute: {
143143 return stub. actions. count > 1 ? stub. actions. removeFirst ( ) : stub. actions. first
@@ -166,14 +166,14 @@ public class MockManager {
166166 }
167167 }
168168
169- private func callThrowsInternal< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) async throws -> OUT , defaultCall: ( ) async throws -> OUT ) async throws -> OUT {
169+ private func callThrowsInternal< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: ( ) async throws ( ERROR ) -> OUT , defaultCall: ( ) async throws ( ERROR ) -> OUT ) async throws ( ERROR ) -> OUT {
170170 let stubCall = ConcreteStubCall ( method: method, parameters: escapingParameters)
171171 queue. sync {
172172 stubCalls. append ( stubCall)
173173 unverifiedStubCallsIndexes. append ( stubCalls. count - 1 )
174174 }
175175
176- if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
176+ if let stub = ( stubs. filter { $0. method == method } . compactMap { $0 as? ConcreteStub < IN , OUT , ERROR > } . filter { $0. parameterMatchers. reduce ( true ) { $0 && $1. matches ( parameters) } } . first) {
177177
178178 guard let action = queue. sync ( execute: {
179179 return stub. actions. count > 1 ? stub. actions. removeFirst ( ) : stub. actions. first
@@ -202,14 +202,14 @@ public class MockManager {
202202 }
203203 }
204204
205- public func createStub< MOCK: ClassMock , IN, OUT> ( for _: MOCK . Type , method: String , parameterMatchers: [ ParameterMatcher < IN > ] ) -> ClassConcreteStub < IN , OUT > {
206- let stub = ClassConcreteStub < IN , OUT > ( method: method, parameterMatchers: parameterMatchers)
205+ public func createStub< MOCK: ClassMock , IN, OUT, ERROR > ( for _: MOCK . Type , method: String , parameterMatchers: [ ParameterMatcher < IN > ] ) -> ClassConcreteStub < IN , OUT , ERROR > {
206+ let stub = ClassConcreteStub < IN , OUT , ERROR > ( method: method, parameterMatchers: parameterMatchers)
207207 stubs. insert ( stub, at: 0 )
208208 return stub
209209 }
210210
211- public func createStub< MOCK: ProtocolMock , IN, OUT> ( for _: MOCK . Type , method: String , parameterMatchers: [ ParameterMatcher < IN > ] ) -> ConcreteStub < IN , OUT > {
212- let stub = ConcreteStub < IN , OUT > ( method: method, parameterMatchers: parameterMatchers)
211+ public func createStub< MOCK: ProtocolMock , IN, OUT, ERROR > ( for _: MOCK . Type , method: String , parameterMatchers: [ ParameterMatcher < IN > ] ) -> ConcreteStub < IN , OUT , ERROR > {
212+ let stub = ConcreteStub < IN , OUT , ERROR > ( method: method, parameterMatchers: parameterMatchers)
213213 stubs. insert ( stub, at: 0 )
214214 return stub
215215 }
@@ -327,11 +327,11 @@ extension MockManager {
327327
328328extension MockManager {
329329 public func getterThrows< T> ( _ property: String , superclassCall: @autoclosure ( ) throws -> T , defaultCall: @autoclosure ( ) throws -> T ) throws -> T {
330- return try callThrows ( getterName ( property) , parameters: Void ( ) , escapingParameters: Void ( ) , superclassCall: try superclassCall ( ) , defaultCall: try defaultCall ( ) )
330+ return try callThrows ( getterName ( property) , parameters: Void ( ) , escapingParameters: Void ( ) , errorType : ( Error ) . self , superclassCall: try superclassCall ( ) , defaultCall: try defaultCall ( ) )
331331 }
332332
333333 public func getterThrows< T> ( _ property: String , superclassCall: @autoclosure ( ) async throws -> T , defaultCall: @autoclosure ( ) async throws -> T ) async throws -> T {
334- return try await callThrows ( getterName ( property) , parameters: Void ( ) , escapingParameters: Void ( ) , superclassCall: try await superclassCall ( ) , defaultCall: try await defaultCall ( ) )
334+ return try await callThrows ( getterName ( property) , parameters: Void ( ) , escapingParameters: Void ( ) , errorType : ( Error ) . self , superclassCall: try await superclassCall ( ) , defaultCall: try await defaultCall ( ) )
335335 }
336336}
337337
@@ -346,11 +346,11 @@ extension MockManager {
346346}
347347
348348extension MockManager {
349- public func callThrows< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: @autoclosure ( ) throws -> OUT , defaultCall: @autoclosure ( ) throws -> OUT ) throws -> OUT {
349+ public func callThrows< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , errorType : ERROR . Type , superclassCall: @autoclosure ( ) throws ( ERROR ) -> OUT , defaultCall: @autoclosure ( ) throws ( ERROR ) -> OUT ) throws ( ERROR ) -> OUT {
350350 return try callThrowsInternal ( method, parameters: parameters, escapingParameters: escapingParameters, superclassCall: superclassCall, defaultCall: defaultCall)
351351 }
352352
353- public func callThrows< IN, OUT> ( _ method: String , parameters: IN , escapingParameters: IN , superclassCall: @autoclosure ( ) async throws -> OUT , defaultCall: @autoclosure ( ) async throws -> OUT ) async throws -> OUT {
353+ public func callThrows< IN, OUT, ERROR > ( _ method: String , parameters: IN , escapingParameters: IN , errorType : ERROR . Type , superclassCall: @autoclosure ( ) async throws ( ERROR ) -> OUT , defaultCall: @autoclosure ( ) async throws ( ERROR ) -> OUT ) async throws ( ERROR ) -> OUT {
354354 return try await callThrowsInternal ( method, parameters: parameters, escapingParameters: escapingParameters, superclassCall: superclassCall, defaultCall: defaultCall)
355355 }
356356}
0 commit comments