danielsaidi / MockingKit

MockingKit is a Swift SDK that lets you easily mock protocols and classes in `Swift`.
MIT License
87 stars 7 forks source link

Mock doesn't work with generics #8

Closed danielsaidi closed 4 years ago

danielsaidi commented 4 years ago

Mock's function address approach doesn't work with Swift generics:

class MyMock<T>: Mock {

    func doit(thing: T) {
        invoke(doit, args: (thing))
    }
}

class MyTestClass: MyMock<String> {}

class GenericTests: QuickSpec {
    override func spec() {

        describe("memory address") {

            it("should be equal") {
                let obj = MyTestClass()
                obj.doit(thing: "")
                let addr1 = obj.address(of: obj.doit)
                let addr2 = obj.address(of: obj.doit)  // Should be equal to addr1, is different
                let inv = cl.invokations(of: cl.doit)      // Should be 1, will be 0
            }
        }
    }
}
danielsaidi commented 4 years ago

This works in 0.4.0