-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Support for generic type matching #95
Comments
Hey @mtwichel yup it’s a duplicate and I’ll try to get that merged and published in the next few days 👍 |
Thanks as always @felangel 🎉🎉 |
@felangel @mtwichel I think the prs 66/67 were referring to fixing the verify issue: But I am still having the issue with when/return as described in the original question: Could either of you confirm whether the when/return generic has been implemented or not? |
Can you provide a link to a minimal reproduction sample? I'm happy to take a look 👍 |
So making a simplified project proved that Mocktail does handle generics correctly. From that I have managed to solve my issue 🎉 |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I am trying to make an object that supports the following type of method:
and I was hoping to mock it like so
Unfortunately, this throws the following error:
_TypeError (type 'String' is not a subtype of type 'int')
Describe the solution you'd like
It would be awesome if when mocking generics, Mocktail would be able to tell the difference between these two methods so the above test would pass.
Describe alternatives you've considered
I really don't think I could have an alternative solution without substantially changing how the object works.
Additional context
I believe the
_useMatchedInvocationIfSet
method (inlib/src/_is_invocation.dart
, line102
) may be where a check that the invocation supports not only the same arguments but the same generic type definitions as well. In the passed invocation object, there is a field called_typeArguments
that contains a list of the generic types passed into the invocation. I think we could add this as criteria for matching invocation and it would support this feature.Thanks in advance! As always, I'm super grateful for everything you and this package bring to the Dart ecosystem, and I'm happy to help with a PR if you think this is worthwhile!
The text was updated successfully, but these errors were encountered: