Comments (3)
On Tue, Apr 9, 2013 at 11:48 PM, fluentfuture [email protected]:
Hi.
Has it been considered that the ASSERT.that(list).has().allOf(foo,
bar).inOrder() be changed to ASSERT.that(list).hasAllOf(foo,
bar).inOrder()? And same for the rest of Has?Or, is there a discussion where hasBlah() was voted out in favor of
has().blah()?The way it is the has() methods seems a little hiccupy as opposed to
"fluent" to me. And it probably pose some discoverability issue to
unfamiliar users because one has to type "has()." first in order to see the
things he's really looking for.Also, I have the habit of writing chained method calls one at a line, but
the has() makes it odd to read:ASSERT.that(list)
.has()
.allOf(foo, bar)
.inOrder();Because has() and allOf() are parts of the same atomic clause of the
sentence, with neither alone makes the sense.Imho, it looks more natural as:
ASSERT.that(list)
.hasAllOf(foo, bar)
.inOrder();Where each line states a single but atomic aspect of assertion.
There's nothing to stop you doing:
ASSERT.that(list)
.has().allOf(foo, bar)
.inOrder();
We could potentially roll some common cases into hasXxx() but we'll always
need has() for extensibility.
Christian probably has more of an opinion than I do on this. If there are
dozens of cases to roll in, I'd vote against but if there are two or three
really obvious wins then it might be worth it.
hasAllOf()
hasAnyOf()
hasNoneOf()
hasAtLeastNOf() - probably not a great idea ...
hasAtMostNOf() - ditto ...
...
I feel like there's diminishing returns from here on, but I might be
missing a whole class of predicates.
Cheers,
David
from truth.
I guess I'm just not used to this style maybe.
Either hasAllOf() or has(allOf()) reads more natural to me than has().allOf().
Instead of fluent, it reads hiccupy to me. The extra pair of parens serve to distract the eyes. At first sight my eyes were wondering what stops it from being:
has().all().of(foo, bar).in().order();
has().none().of(foo, bar).not().in().order();
Where do we draw the line?
(I'm semi-serious)
But thanks for explaining the rationale! I'm closing the issue since apparently it's only me feeling the issue.
from truth.
has().allOf/anyOf/exactly/item() there are two distinct things - a verb
and an object.
inOrder() is a single concept. in is a preposition and is entirely a
lead-up. One could say ordered() but inOrder() is more natural to an
english speaker.
notInOrder() isn't needed because that is the default - the looser
constraint
On 11 Apr 2013, at 10:24, fluentfuture wrote:
I guess I'm just not used to this style maybe.
Either hasAllOf() or has(allOf()) reads more natural to me than
has().allOf().Instead of fluent, it reads hiccupy to me. At first sight my eyes were
wondering what stops it from being:has().all().of(foo, bar).in().order();
has().none().of(foo, bar).not().in().order();
Where do we draw the line?
(I'm semi-serious)
But thanks for explaining the rationale! I'm closing the issue since
apparently only me is feeling the issue.
Reply to this email directly or view it on GitHub:
#55 (comment)
Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email: [email protected] :::: mobile: +1 (646) 807-9839
from truth.
Related Issues (20)
- Consider reducing ImmutableList array copying HOT 1
- Wanted: Truth8Junit to support Java 8 types with assume() HOT 3
- Compatibility with gradle 7.6 HOT 2
- UsingCorrespondence should fail on use of equals(), like Subject does
- 1.1.4, Guava update leads to java.lang.UnsupportedOperationException at WindowsSecurityDescriptor.java:358 HOT 2
- Add StringSubject isNotBlank or hasText HOT 2
- If matches(x) fails but containsMatch(x) would have passed, suggest containsMatch in the failure message HOT 1
- Compilation error when running maven tests HOT 4
- Could not find com.google.truth.truth:1.1.2:. HOT 1
- Write a comparison to Kluent, AssertK, Strikt, Atrium, Kotest, other Kotlin assertion libraries? HOT 13
- Protobuf: allow unpopulated required fields when `comparingExpectedFieldsOnly` HOT 5
- Truth 1.1+ depends on Java 8 bytecode HOT 3
- FAQ entry: Why we don't support multiple chained calls to assertion methods on the same Subject HOT 3
- Port a core set of unit tests to kotlin HOT 2
- JUnit5 support for the existing soft-assertions support (Expect.create JUnit4 Rule) HOT 5
- Document when arrays are compared by their contents vs. their object identity HOT 3
- New extension for Gradle's TestKit HOT 1
- Asymmetric matchers like Jest's expect.stringContaining("") ? HOT 3
- Add MapSubject#containsAnyOf HOT 2
- Allow logical operations on assertions HOT 4
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 truth.