pyrmont / testament

A testing library for Janet
MIT License
28 stars 8 forks source link

Feature: `each-is` #11

Open subsetpark opened 3 years ago

subsetpark commented 3 years ago

Add a new macro, each-is:

each-is forms &opt note

forms should be a tuple or array of assertion forms, of the same kind understood by is.

(each-is @[foo bar baz] "note") is equivalent to:

(is foo "note")
(is bar "note")
(is baz "note")

original issue text:

(is @[foo bar baz] note) would be equivalent to (is foo note) (is bar note) ...

pyrmont commented 3 years ago

Would it be better to have a separate are macro for this? While this looks helpful in the abstract, it also seems to confuse the semantics of is. To be clear, it doesn't have to be are and could be something that makes the relationship to is clearer (e.g. is-multi, is-group, iss, etc).

subsetpark commented 3 years ago

Yeah, I think that’s right. I’m not a fan of those bdd-style libraries that try to give you an English word for everything you might want to say, but the aim of keeping a simple and consistent semantics for the function itself is quite worthwhile.

pyrmont commented 3 years ago

Yeah, I'm similar. I'm a worried that are is a little too clever by half. I didn't really like the other alternatives, though. If it was a separate macro, do you have a name you'd prefer? is-all? is-every?

subsetpark commented 3 years ago

each-is maybe? each is already a word

pyrmont commented 3 years ago

That one sounds good to me: clear and easy to understand.