uber / mockolo

Efficient Mock Generator for Swift
Apache License 2.0
804 stars 85 forks source link

[BUG] Mocking functions with `for` parameter + include-history #237

Closed alexdremov closed 1 year ago

alexdremov commented 1 year ago

This produces non-compilable result:

/// @mockable(history: canRequest = true)
public protocol Foo {
    func biz(for: String) -> Bool
}

Results in

public class FooMock: Foo {
    public init() { }

    public private(set) var bizCallCount = 0
    public var bizArgValues = [String]()
    public var bizHandler: ((String) -> (Bool))?
    public func biz(for: String) -> Bool {
        bizCallCount += 1
        bizArgValues.append(for)
        if let bizHandler = bizHandler {
            return bizHandler(`for`)
        }
        return false
    }
}

And this does not compile because for is not escaped in bizArgValues.append(for)