Open johlrogge opened 11 years ago
Hey, just wanted to say that structure
is really cool and most probably going to be very useful.
I didn't see it just from attr
, but now I do.
Only the name... you know ;) but that can wait. I'm thinking "structural match 2.0" (or "up to 11" if you like)...?
It's the sugar that makes the cake :)
Re what makes the cake: ever been invited by "organic rads" for coffee and cake? I was just recently, so I mean it!!
Thanks. I really wanted to get assert.structure in there because it sort of gives a good example of the vision. But i didn't want to start in that end since the cool stuff is actually how the assertions are combined underneath.
I have now tested the failure messages of assert structure. Atm they are fail fast which is probably not a bad thing. It makes messages easier. Combining asserts really becomes a breeze with the new promise based raw
assertions.
I have added an
assert.structure
It is basically a syntactic sugar on assertion combinators. At the moment it treats all functions as if they are explicit assertions in the structure and generates
combinators.assert.equals(expected)
for everything else.example:
is roughly equivalent to:
The
function(actual)
should of course be replaced with anall
combinator etc but they do not exist yet.I think that this kind of sugaring will be very useful for testing with promises. From my own experience so far it would be really useful to be able to look inside resolved values this way without returning a different resolved value. That allows you to look into promise chains in the same way you can do with
_.tap
but also readable.