My current contract requires me to write CoffeeScript. It's a struggle but you get used to it. One of the things CS does drastically different from JS is parenthesis; calls don't need them unless there are no arguments. This leads to the following code block, found in some test file that I wrote:
it 'should require domains', ->
expect(-> domain_divby).to.throw()
expect(-> domain_divby []).to.throw()
expect(-> domain_divby null, []).to.throw()
Now, this isn't too bad. I think the arrow syntax is perfect for something like this, where chai requires a function wrapper around code that I want to confirm does or does not throw. And instead of having to wrap it in a function(){...}
block, I can just prefix it with ->
.
There is a problem with one line of the above code though, can you spot it? It's not going to do what you expect it to do and the test will fail. But it's only a test setup problem.
The only reason this test slipped through is because initially I had it like this
it 'should require domains', ->
expect(-> domain_divby).to.throw
expect(-> domain_divby []).to.throw
expect(-> domain_divby null, []).to.throw
Prose is nice, but in this case it led to a dud test; it's simply not doing anything because nothing is being called. Mah bad.