Skip to content

Comment on Extending JavaScript with inline unit tests

Comments

This technique is not called "Inline unit tests", it's called contract programming.

I can't imagine writing such code without proper support from IDE like automatic folding and/or special colors.

There is also problem of asynchronous code, events etc. Something that can't be covered with such simple contracts.

Given the simplicity of my macro, I didn't call this 'contract programming' on purpose. For real JavaScript Contract Programming, check out contracts.js (from the same author of sweet.js).

Among others(there are many contract implementations for js on github) this one is pretty average, not modern enough, not compatible with code which uses promises. Such implementation should go beyond direct arguments and result value of function call.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.