-
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
matchers: nicer syntax for Type testing #10407
Comments
cc @sigmundch. |
cc @gramster. |
Initially we took this approach because we could not rely on 'is' in dart2js if the type was passed as a parameter. Perhaps there is enough reflection support now to make this work; will have to investigate. In the meantime, a workaround is to define matcher instances for the types you care about (the library already does this for most exception and error types). E.g. final is_int = new predicate((x) => x is int, "is an int"); |
Added Pkg-Unittest label. |
Removed Area-unittest label. |
This issue has been moved to dart-lang/test#214. |
This issue was originally filed by @seaneagan
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
currently it doesn't read as nicely as other matchers:
expect(x, new isInstanceOf<int>());
expect(f, throwsA(new isInstanceOf<ExpectedError>()));
better would be:
expect(x, isA(int));
expect(f, throwsA(isA(ExpectedError)));
or even:
expect(x, int);
expect(f, throwsA(ExpectedError));
I think this is blocked on issue #10406.
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: