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

Add back support for explicit template for *Return(obj). #337

Open
4 tasks
FranckRJ opened this issue May 26, 2024 · 0 comments
Open
4 tasks

Add back support for explicit template for *Return(obj). #337

FranckRJ opened this issue May 26, 2024 · 0 comments
Labels
Milestone

Comments

@FranckRJ
Copy link
Collaborator

The syntax .Return<type>(obj) to force the object to be copied and .Return<type&>(obj) to force the object to be captured by reference have been removed by #330 be caused it caused issues with the new implementation of .Return(obj), and because it was not a real documented feature (but more a by-product of the implementation), I supposed no one was relying on it.

It turns out that some people use this feature (see #200 (comment) and #336 (comment)), not only to change the behavior of .Return(obj), but also to have a consistent behavior, i.e. having .Return(obj) do the same thing regardless of if the mocked function return a reference or an object.

What should be done:

  • Reintroduce back the support for .Return<type>(obj) and .Return<type&>(obj) to not break to much code with the new update, maybe mark them as deprecated.
  • Make .ReturnCapture(obj) available on any function (those that return a reference and those that does not) so it can be used as a default when the user ALWAYS want to capture the value of the object, regardless of the return type of the mocked function.
  • Add an equivalent to .ReturnCapture(obj) but that forces the capture of the object by reference, this feature already as its own issue ((Always)Return doesn't seem to allow capturing locals by reference? #200).
  • Extend the two functions mentioned above so they support the extra features of Return (e.g. .Return(obj1, obj2, ...), .Return(val_Times(5)), maybe more).
@FranckRJ FranckRJ added this to the 2.5.0 milestone May 26, 2024
@FranckRJ FranckRJ added the bug label Jun 6, 2024
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

1 participant