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 Mock Syntax Errors #1

Open
JRG-Developer opened this issue Mar 18, 2016 · 13 comments
Open

Class Mock Syntax Errors #1

JRG-Developer opened this issue Mar 18, 2016 · 13 comments

Comments

@JRG-Developer
Copy link

@TadeasKriz I'm opening this issue per our discussion on Cuckoo repository.

Per the README, CuckooGenerator supports mocks created from classes.

In my testing, however, I cannot get this to work. Rather, there are always several syntax errors.

CuckooTestDummy is a dummy test project that showcases the errors I'm seeing.

@TadeasKriz
Copy link
Member

This seems to be a problem with NSObject class or required initializers. I will look into it during the weekend and see if I can find a fix.

@JRG-Developer
Copy link
Author

Cool, thanks @TadeasKriz !

If I can figure out the cause, I'll open a PR. ;)

@TadeasKriz
Copy link
Member

Thanks!

From what I see, it is the logic of tokenization and generation of initializers. I probably completely forgot about custom initializers as I added class support in a bit of a hurry. Great catch! :)

@TadeasKriz
Copy link
Member

Hey, @a-voronov added basic support for initializers, I'll give the dummy project a try :)

@TadeasKriz
Copy link
Member

Unfortunately, no dice, it will need more work.

@a-voronov
Copy link
Contributor

@TadeasKriz Thanks!
Yep, there are more issues with generating mocks for classes. Protocols though seem to be generated correctly, but need to verify more edge cases.

Cuckoo.StubbingProxy and Cuckoo.VerificationProxy generate generic initializers with func keywords which is incorrect.

@TadeasKriz
Copy link
Member

@a-voronov I'm aware of these problems. Fortunately @FilipDolnik is working on tests for the generator, so it will be easier to test more files whether or not the generator works as expected.

@bobbelkl
Copy link

Any news on the initializers issue?

@wfrank2509
Copy link

It would be great to be able to Mock classes with custom initializers as this is typically heavily used in our projects or dependent frameworks where we do not have much influence on the structure.

Is there a timeline or any plans for working on this issue? Thanks!

@TadeasKriz
Copy link
Member

TadeasKriz commented Sep 8, 2016

Hey guys, new Cuckoo 0.7.0 is out with fixed initializers issue :) Sorry for the long wait.

@wfrank2509
Copy link

Great Job. Thank you!

@0xPr0xy
Copy link

0xPr0xy commented Jan 11, 2017

Hey guys,

I'm having an issue related to initializers, so I thought I could add it to this thread.
When generating a mock for a class with a deinit method, I'm receiving the following syntax error in GeneratedMocks.swift -> Keyword 'deinit' cannot be used as an identifier here

I've looked at the Generator code a bit and was able to reproduce this with ./runcuckoo generate test.swift (the test.swift being a simple swift class with a deinit method), however I'm not familiar enough with the way the GeneratedMocks.swift works to be sure I actually fix the problem.

I think it could be fixed in Generator.swift:86, Generator.swift:113 and by adding the isDeinit to the Token.swift class.
Hope you can fix this or help me

@mrgerych
Copy link

@0xPr0xy check my PR. it fix deinit issue

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

No branches or pull requests

7 participants