Skip to content

Commit 2f611e5

Browse files
committed
Added test for asserting unsupported hooking of class methods
1 parent 0037574 commit 2f611e5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@testable import InterposeKit
2+
import XCTest
3+
4+
final class ClassMethodInterposeTests: InterposeKitTestCase {
5+
6+
func testClassMethod() {
7+
XCTAssertThrowsError(
8+
try Interpose(TestClass.self) {
9+
try $0.prepareHook(
10+
#selector(getter: TestClass.staticInt),
11+
methodSignature: (@convention(c) (AnyObject, Selector) -> Int).self,
12+
hookSignature: (@convention(block) (AnyObject) -> Int).self
13+
) { hook in
14+
return { _ in 73 }
15+
}
16+
}
17+
) { error in
18+
let typedError = error as! InterposeError
19+
XCTAssertEqual(typedError, .methodNotFound(TestClass.self, #selector(getter: TestClass.staticInt)))
20+
}
21+
}
22+
23+
}

Tests/InterposeKitTests/TestClass.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public extension CATransform3D {
2323
}
2424

2525
class TestClass: NSObject {
26+
27+
@objc dynamic static var staticInt = 42
2628

2729
@objc dynamic var age: Int = 1
2830
@objc dynamic var name: String = "Tim Apple"

0 commit comments

Comments
 (0)