-
Notifications
You must be signed in to change notification settings - Fork 179
Fix lot of stuffs with .*Return*. #356
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
Conversation
|
Hello @otrempe and @malcolmdavey, from what I understood from things you said in other issues, you have some codebases that use explicit template specializations for If you can, I would like you to test this PR with your codebase (I already generated the single headers here: https://github.com/eranpeer/FakeIt/tree/make-return-with-spe-works-again-and-bonuses/single_header), because previous versions of FakeIt 2.5.0-dev disabled this (undocumented) feature, but I tried to add it back, and I would like to know if it works for more complexes use cases than the ones I come up in the unit tests. I would really like to be able to release 2.5.0 without breaking anyone's code, if anyone can help I would be really grateful. |
Hi Frank. As it turns out I hadn't actually used any cases of explicit types yet, but had just added unit tests for fakeit to give more complete coverage. My existing code (using fakeit 2.4 ?) Now compared to AlwaysReturn/Return, since it doesn't know the type, I need to make the type explicit I guess this is less ideal compared to the behaviour of Return/AlwaysReturn, but it isn't a big deal. |
|
Also found an unrelated compile error here that I posted here |
|
I didn't thought about that, yeah adding a default type for the template so you don't need to explicitly provide one is easy, I tried on Godbolt and it works, I'll change that. Thank you for the suggestion ! Thanks for reporting the bug with msvc, I'll fix that as well. |
…returning a reference, and improved ReturnCapture to construct the return type from the parameter if their reference is not compatible (to allow things like function-returning-std-string.ReturnCapture("string")).
…and added some tests.
…eference (in a deprecated manner), and other minor fixes.
0d2e906 to
cece5b1
Compare
|
I think it's in a pretty good state, so I'll merge it now. If issues are found I hope they won't be too big, and they can always be fixed in a later release. |
Basically what's here: #337.
What this PR do:
.Return<type>(obj)and.Return<type&>(obj)to not break to much code with the new update, they are deprecated and shouldn't be used.ReturnValCaptandReturnRefCaptto force a capture either by value (move or copy) or by reference, independent of the return type of the mocked function.T&,ReturnValCapt(U{})will store the original object ifU&can be cast toT&(ifTis a parent ofU, for example) to avoid object slicing, otherwise aTwill be constructed from theUpassed by parameter and stored, to avoid creating a temporary (and returning a reference to it) when the mocked function is called.