joshgoebel / wren-testie

Simple and beautiful testing for Wren
MIT License
8 stars 2 forks source link

[enhancement] add informal aliases for Expect tests. #4

Open glennj opened 3 years ago

glennj commented 3 years ago
equals, doesNotEqual
isGreaterThan, isLessThan, isGreaterThanOrEqual, isLessThanOrEqual
isNull, isNotNull
hasSameItemsAs
abortsWith, doesNotAbort

These look nice, shouldn't this also include isEqual and isNotEqual though?

Originally posted by @joshgoebel in https://github.com/joshgoebel/wren-testie/issues/3#issuecomment-907500977

glennj commented 3 years ago

This would un-deprecate abortsWith

joshgoebel commented 3 years ago

For completeness also isSameItemsAs? Thoughts?

glennj commented 3 years ago

Indeed, I missed that one.

Although I find toIncludeSameItemsAs pretty niche. Have you had circumstances where you need that kind of test? It strikes me that would be a time to write a Set class with an == method.

joshgoebel commented 3 years ago

I added things as needed so I bet it was used in one of the test suites... IIRC its useful for resolving indeterminate order results without having to sort() both sides [which is stupidly annoying] for equality. To me it seems a useful assertion for exactly that purpose, though perhaps there is a better name to be found?

glennj commented 3 years ago

No suggestions for improvement, except that wren needs a sorted() method that returns a new list, leaving the original untouched.

sorted() { this[0..-1].sort() }
sorted(comparer) { this[0..-1].sort(comparer) }
joshgoebel commented 3 years ago

Perhaps. :-)

I'd still hate to type sorted() everywhere. Seems like this is a problem a test library is well suited to solve for the user, no? :-)

joshgoebel commented 3 years ago

except that wren needs a sorted() method that returns a new list,

You could open an issue on wren/wren.

glennj commented 3 years ago

Although I find toIncludeSameItemsAs pretty niche. Have you had circumstances where you need that kind of test?

Self-answering: https://github.com/exercism/wren/blob/108b9a3c429f904dbabf3c50e02ad7d3084c6e90/exercises/practice/custom-set/custom-set.spec.wren#L237

joshgoebel commented 3 years ago

Yes, I didn't add it for no reason. 🤪