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

matchers: nicer syntax for Type testing #10407

Closed
DartBot opened this issue May 3, 2013 · 7 comments
Closed

matchers: nicer syntax for Type testing #10407

DartBot opened this issue May 3, 2013 · 7 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented May 3, 2013

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.

@madsager
Copy link
Contributor

madsager commented May 3, 2013

cc @sigmundch.
Added Area-Pkg, Triaged labels.

@sigmundch
Copy link
Member

cc @gramster.
Removed Area-Pkg label.
Added Area-unittest label.

@gramster
Copy link
Contributor

gramster commented May 3, 2013

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");

@gramster
Copy link
Contributor

Added Duplicate label.
Marked as being merged into #8138.

@kevmoo
Copy link
Member

kevmoo commented Feb 12, 2014

Added Pkg-Unittest label.

@kevmoo
Copy link
Member

kevmoo commented Feb 12, 2014

Removed Area-unittest label.
Added Area-Pkg label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/test#214.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

5 participants