CoReturn can return implicitly convertible values
Summary: Gmock's `Return(x)` is a valid action as long as `x` is implicitly convertible to the return type of the function. The current implementation of `CoReturn(x)` does not support that, since `Task<T>` is not convertible to `Task<Q>` even if `Q` is convertible to `T`. This diff changes the `CoReturn` implementatio to match the way Gmock does, allowing for the implicit conversion. This is extremely valuable when using `Task<Expected<...>>`, as it allows to write `CoReturn(makeUnexpected(...))` instead of `CoReturn(Expected<...>(unexpected, ...))`. It also make the translation from a mock being sync to async more straightforward: add `Task` in the mock return type and replace `Return` with `CoReturn`. Reviewed By: lewissbaker Differential Revision: D24046013 fbshipit-source-id: 9f166237a624600be51c00616f145ae4e1a45443
Showing
Please register or sign in to comment