matcher
matcher copied to clipboard
`expect` functions should be typed
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
You can try our work in progress new matching library which is type safe, https://github.com/dart-lang/test/tree/master/pkgs/checks
@jakemac53 thanks! is there an issue tracking the progress of the new library? if so i can close this issue
cc @natebosch who is working on it
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.
i get that, thought imo that's an edge case you can easily work around by explicitly specifying the generic:
checkThat<Object>(1).equals('');