On Tuesday, 30 June 2015 at 11:14:55 UTC, Atila Neves wrote:
On Tuesday, 30 June 2015 at 08:38:44 UTC, Adrian Matoga wrote:
On Tuesday, 30 June 2015 at 08:06:37 UTC, Atila Neves wrote:
I'm not convinced composability brings anything to the table
except for editor dot-completion. I don't like the verbosity
of what's there now, but my prefererred syntax doesn't work
except for the ubiquitous check for equality (`should ==`).
Could you give some examples of your preferred syntax and why
it doesn't work?
`foo.should == "bar";` works. Nothing else does (and in fact in
retrospect it's surprising that == does) because they do
nothing by themselves. `foo.should != bar` is the same as
`!(foo == bar)`, which on a statement by itself is nonsensical
and rejected by the compiler with "has no effect in expression"
error. You could write something like `if(foo.should != "bar")
{}` and that compiles fine but it's super hacky and ugly.
Atila
Thanks. I took a second look and now it looks obvious.
I'd vote for Dicebot's bikeshed design (2b). It's short and looks
equally readable for every possible test.
Another hackish possibility could be to change the behavior of
assert so that it also passes the stringified expression to
_d_assert* and _d_unittest* in druntime.