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

expect functions should be typed #234

Open
DetachHead opened this issue Jun 28, 2022 · 5 comments
Open

expect functions should be typed #234

DetachHead opened this issue Jun 28, 2022 · 5 comments

Comments

@DetachHead
Copy link

expect(1, ""); // no compile error

it's annoying when my tests fail due to the expected and actual values being incompatible types. the compiler should be able to identify these issues before the tests are run

@jakemac53
Copy link
Contributor

You can try our work in progress new matching library which is type safe, https://github.com/dart-lang/test/tree/master/pkgs/checks

@DetachHead
Copy link
Author

@jakemac53 thanks! is there an issue tracking the progress of the new library? if so i can close this issue

@jakemac53
Copy link
Contributor

cc @natebosch who is working on it

@lrhn
Copy link
Member

lrhn commented Jun 30, 2022

Also, for the record, very few types are strictly incompatible, to the point where no object can implement both, and also the == operator can accept objects of other types, so expect(v1, v2) isn't necessarily false when v1 and v2 have unrelated types.

@DetachHead
Copy link
Author

i get that, thought imo that's an edge case you can easily work around by explicitly specifying the generic:

checkThat<Object>(1).equals('');

@natebosch natebosch transferred this issue from dart-lang/test Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants