Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class func not supported #521

Open
nmoersch-calimoto opened this issue Nov 12, 2024 · 1 comment
Open

class func not supported #521

nmoersch-calimoto opened this issue Nov 12, 2024 · 1 comment
Labels

Comments

@nmoersch-calimoto
Copy link

I know that static methods can't be overridden and are unsupported. But when one class func function exists in a class that should be mocked, the generated Mock cannot be compiled anymore, as Cuckoo tries (and fails) to write a mock for this class func.

Mocked class funcs can't really be used, as they would need to be called directly on the Mock-Type, which is probably not available in the tested context. And even if: Then just the mock is being tested and nothing is actually happening.

It should either be marked as unsupported and not result in compilation errors, or the problems can somehow be solved.

Input (e.g.):

public class func isUsingFullAccuracy() -> Bool {
    let manager: CLLocationManager = CLLocationManager()
    return manager.accuracyAuthorization == .fullAccuracy
}

Output:

override func isUsingFullAccuracy() -> Bool {
    return cuckoo_manager.call(
        "isUsingFullAccuracy() -> Bool",
        parameters: (),
        escapingParameters: (),
        superclassCall: super.isUsingFullAccuracy(),
        defaultCall: __defaultImplStub!.isUsingFullAccuracy()
    )
}

Compilation Errors are then:

  • Method does not override any method from its superclass
    • because the class keyword is missing
  • 2x Static member 'isUsingFullAccuracy' cannot be used on instance of type Xyz
    • at superclassCall & defaultCall, because its a class func
@MatyasKriz MatyasKriz added the bug label Nov 14, 2024
@MatyasKriz
Copy link
Collaborator

Thanks for the report! Frankly I never use these so I forgot about ignoring them during crawling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants