-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use runtimeType in expect/throwsA #8138
Comments
This comment was originally written by @sethladd Drat. Title should be something like: "Add a match to match against type" |
Notice that this only tests for type equality, not subtype relation. It really needs to be a subtype test in order to maintain the substitution principle. In the longer run, we might want to allow type objects as the right-hand operand of the "is" operator. Added Area-Pkg, Package-Unittest, Triaged labels. |
This comment was originally written by @butlermatt I'm curious why this error does not have a pre-set matcher similar to 'throwsArgumentError' or 'throwsRangeError' etc. I realize not all errors are represented here but I would think stateError to be used enough to warrant its inclusion. |
It should be. I think it's just that the pre-set matchers were created before the Great Exception Type Cleanup of 2013. File a separate bug for this? |
This comment was originally written by @sethladd One step ahead: http://code.google.com/p/dart/issues/detail?id=8137 :) |
This comment was originally written by @sethladd Lasse, you're right. I poorly worded the title. Instead, a better title should be: "Add a matcher that tests an object's type and that works in dart2js" Thanks for the clarification! |
I'm not sure now whether you still want this, Seth. It seems without subtype support it isn't very useful. |
Yes. |
Issue #10407 has been merged into this issue. |
This comment was originally written by @seaneagan This should be marked as blocked on issue #10406. |
Added AssumedStale label. |
This issue was originally filed by @sethladd
This doc is what the docs recommends:
expect(() => store.keys(), throwsA(new isInstanceOf<StateError>()));
However, we now have .runtimeType. Can we instead make the matcher more simple?
This works:
test(obj, Type type) {
return (obj.runtimeType == type);
}
void main() {
print(test(new StateError('foo'), StateError));
}
I'd love to see:
expect(() => store.keys(), throwsA(StateError));
Thoughts?
The text was updated successfully, but these errors were encountered: