@@ -150,7 +150,64 @@ final class ObjectInterposeTests: InterposeKitTestCase {
150150 try hook. revert ( )
151151 XCTAssertEqual ( testObj. doubleString ( string: str) , str + str)
152152 }
153-
153+
154+ func testHook_getPoint( ) throws {
155+ let object = TestClass ( )
156+ XCTAssertEqual ( object. getPoint ( ) , CGPoint ( x: - 1 , y: 1 ) )
157+
158+ let hook = try object. hook (
159+ #selector( TestClass . getPoint) ,
160+ methodSignature: ( @convention( c) ( NSObject, Selector) - > CGPoint) . self,
161+ hookSignature: ( @convention( block) ( NSObject) - > CGPoint) . self
162+ ) { hook in
163+ return { `self` in
164+ var point = hook. original ( self , hook. selector)
165+ point. x += 2
166+ point. y += 2
167+ return point
168+ }
169+ }
170+
171+ XCTAssertEqual ( object. getPoint ( ) , CGPoint ( x: 1 , y: 3 ) )
172+
173+ try hook. revert ( )
174+ XCTAssertEqual ( object. getPoint ( ) , CGPoint ( x: - 1 , y: 1 ) )
175+ }
176+
177+ func testHook_passthroughPoint( ) throws {
178+ let object = TestClass ( )
179+
180+ XCTAssertEqual (
181+ object. passthroughPoint ( CGPoint ( x: 1 , y: 1 ) ) ,
182+ CGPoint ( x: 1 , y: 1 )
183+ )
184+
185+ let hook = try object. hook (
186+ #selector( TestClass . passthroughPoint ( _: ) ) ,
187+ methodSignature: ( @convention( c) ( NSObject, Selector, CGPoint) - > CGPoint) . self,
188+ hookSignature: ( @convention( block) ( NSObject, CGPoint) - > CGPoint) . self
189+ ) { hook in
190+ return { `self`, inPoint in
191+ var outPoint = hook. original ( self , hook. selector, inPoint)
192+ outPoint. x += 1
193+ outPoint. y += 1
194+ return outPoint
195+ }
196+ }
197+
198+ XCTAssertEqual (
199+ object. passthroughPoint ( CGPoint ( x: 1 , y: 1 ) ) ,
200+ CGPoint ( x: 2 , y: 2 )
201+ )
202+
203+ try hook. revert ( )
204+
205+ XCTAssertEqual (
206+ object. passthroughPoint ( CGPoint ( x: 1 , y: 1 ) ) ,
207+ CGPoint ( x: 1 , y: 1 )
208+ )
209+ }
210+
154211// func testLargeStructReturn() throws {
155212// let testObj = TestClass()
156213// let transform = CATransform3D()
0 commit comments