@@ -92,6 +92,87 @@ final class UT_SpyFactory: XCTestCase {
9292 )
9393 }
9494
95+ func testDeclarationOptionalExistentialTypeArguments( ) throws {
96+ try assertProtocol (
97+ withDeclaration: """
98+ protocol ViewModelProtocol {
99+ func foo(model: (any ModelProtocol)?)
100+ }
101+ """ ,
102+ expectingClassDeclaration: """
103+ class ViewModelProtocolSpy: ViewModelProtocol {
104+ var fooModelCallsCount = 0
105+ var fooModelCalled: Bool {
106+ return fooModelCallsCount > 0
107+ }
108+ var fooModelReceivedModel: (any ModelProtocol)?
109+ var fooModelReceivedInvocations: [(any ModelProtocol)?] = []
110+ var fooModelClosure: (((any ModelProtocol)?) -> Void)?
111+ func foo(model: (any ModelProtocol)?) {
112+ fooModelCallsCount += 1
113+ fooModelReceivedModel = (model)
114+ fooModelReceivedInvocations.append((model))
115+ fooModelClosure?(model)
116+ }
117+ }
118+ """
119+ )
120+ }
121+
122+ func testDeclarationOpaqueTypeArgument( ) throws {
123+ try assertProtocol (
124+ withDeclaration: """
125+ protocol ViewModelProtocol {
126+ func foo(model: some ModelProtocol)
127+ }
128+ """ ,
129+ expectingClassDeclaration: """
130+ class ViewModelProtocolSpy: ViewModelProtocol {
131+ var fooModelCallsCount = 0
132+ var fooModelCalled: Bool {
133+ return fooModelCallsCount > 0
134+ }
135+ var fooModelReceivedModel: (some ModelProtocol)?
136+ var fooModelReceivedInvocations: [some ModelProtocol] = []
137+ var fooModelClosure: ((some ModelProtocol) -> Void)?
138+ func foo(model: some ModelProtocol) {
139+ fooModelCallsCount += 1
140+ fooModelReceivedModel = (model)
141+ fooModelReceivedInvocations.append((model))
142+ fooModelClosure?(model)
143+ }
144+ }
145+ """
146+ )
147+ }
148+
149+ func testDeclarationOptionalOpaqueTypeArgument( ) throws {
150+ try assertProtocol (
151+ withDeclaration: """
152+ protocol ViewModelProtocol {
153+ func foo(model: (some ModelProtocol)?)
154+ }
155+ """ ,
156+ expectingClassDeclaration: """
157+ class ViewModelProtocolSpy: ViewModelProtocol {
158+ var fooModelCallsCount = 0
159+ var fooModelCalled: Bool {
160+ return fooModelCallsCount > 0
161+ }
162+ var fooModelReceivedModel: (some ModelProtocol)?
163+ var fooModelReceivedInvocations: [(some ModelProtocol)?] = []
164+ var fooModelClosure: (((some ModelProtocol)?) -> Void)?
165+ func foo(model: (some ModelProtocol)?) {
166+ fooModelCallsCount += 1
167+ fooModelReceivedModel = (model)
168+ fooModelReceivedInvocations.append((model))
169+ fooModelClosure?(model)
170+ }
171+ }
172+ """
173+ )
174+ }
175+
95176 func testDeclarationEscapingAutoClosureArgument( ) throws {
96177 try assertProtocol (
97178 withDeclaration: """
0 commit comments