Comments (6)
I'm of two minds about this. I see where you're coming from, but I also appreciate the aesthetic value of letting matchers read like sentences where possible—"expect foo is true" reads better than "expect foo true".
If we do decide to do this, I'd want to first improve the output of equals()
so that we don't have angle brackets for objects like booleans whose string output we know to be reasonable.
from matcher.
Added to 1.0.0 milestone so we can either decide not to deprecate, or have them removed before the version bump.
This has come up on mailing lists as a source of confusion, IMO having 1 way to solve this problem outweighs the aesthetics of the call.
It definitely can't hurt to have nicer output from equals()
in any case
from matcher.
One advantage of isTrue
and isFalse
is we could do better static analysis, i.e.:
expect/*Inferred: <bool>*/(someFlag, isTrue);
That means if you accidentally type:
expect('clearlyNotTrue', isTrue);
We could potentially lint this. Just an idea.
from matcher.
Hmm, yeah with #37 these could potentially have more utility.
Though if we work out the T|Matcher<T>
problem that would exist with expect
anyway would we also be able to get the same for expect('notABool', true)
?
Do we see a world where we start requiring equals()
so we can limit the second argument to Matcher
?
from matcher.
Do we see a world where we start requiring
equals()
so we can limit the second argument toMatcher
?
I personally use equals()
a lot, but I'm in the substantial minority there—people really like using bare values, and I'd hate to take that away from them. Also, even I use bare values for operators where it helps the match read like a sentence, such as expect(foo, isNot(12))
. I'd rather just wait for union types.
from matcher.
I'm of two minds about this. I see where you're coming from, but I also appreciate the aesthetic value of letting matchers read like sentences where possible—"expect foo is true" reads better than "expect foo true".
I think that's more about implicit vs. explicit use of equals()
. That's orthogonal to isTrue
vs. equals(true)
, which I think is what this issue is really about.
If we do decide to do this, I'd want to first improve the output of
equals()
so that we don't have angle brackets for objects like booleans whose string output we know to be reasonable.
FWIW, I much prefer the existing output from equals()
. I've been confused by the failure output from isTrue
/isFalse
/isNull
where the expected value is printed without angle brackets but the actual value is printed with them. I then spend time wondering why they're formatted differently (e.g. is the actual value a different type?).
from matcher.
Related Issues (20)
- CustomMatcher example should not use dynamic call
- Un-deprecate isInstanceOf HOT 8
- Matcher request: containsSingle HOT 11
- Matchers handle double.nan unintuitively and inconsistently
- Pretty print with private type names
- Add an extension operator to make it easier to combine matchers HOT 7
- Generic type missing on `_functionMatchers` field in HavingMatcher
- Consider adding `isTypeError` and possibly deprecating `isCastError`? HOT 5
- Several matchers (unordered, containsAll) don't report which element is missing HOT 2
- Implement describeMismatch for TypeMatcher HOT 2
- orderedEquals fails for identical lists of maps<String, dynamic> HOT 4
- ContainsKey matcher for Maps HOT 2
- _DeepMatcher crash on badly behaved Iterable HOT 1
- Add a best practices section in the readme HOT 1
- Add a matcher with custom selector HOT 1
- AllOf() matcher crashes if inner matchers throw HOT 1
- Consider publishing a 1.0.0 release HOT 2
- Prepare for Dart 3 HOT 6
- revert to min sdk 2.12 HOT 11
- analysis failures on the CI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matcher.