zkat / maybe-hugs

Polyglot implementations of conditional hugging
Other
115 stars 25 forks source link

Add tests, and throw when no cutie found #2

Closed isaacs closed 9 years ago

isaacs commented 9 years ago

This adds tests, but also makes some slight semantic changes that I think may have been the original intent.

With this change, calling MaybeHug(cutie) returns either 'HUG!' or 'Empathy!', rather than returning nothing.

Passing null or undefined as the cutie causes it to eagerly throw a TypeError, rather than throwing later when it tries to hug. (In other words, don't try to hug ghosts like null and undefined, they never like it, and are offended by the offer.)

There is now 100% test coverage as well.

zkat commented 9 years ago

Thanks for the contribution, @isaacs though I am concerned about standard compatibility ;)

isaacs commented 9 years ago

I don't think that we should be embracing standard, though we should still show it empathy.

> require('./')(require('standard'))
'Empathy!'