This post originated from an RSS feed registered with Agile Buzz
by Travis Swicegood.
Original Post: Elegantly Simple
Feed Title: Travis Swicegood
Feed URL: http://travisswicegood.com/atom/
Feed Description: Posts on Git from Travis Swicegood, author of Pragmatic Version Control using Git.
JavaScript catches a lot of flack for it’s “ugliness,” but I’m rather fond of
the language. It’s first-class functions make up for any quirks you have to
deal with in the language. Consider this test case:
prompt> vows --spec spec/output.js
⢠output generated by
sync-add.js
â generates 2 lines of output
â "result: 2" is line #1
â "done!" is line #2
async-add.js
â generates 2 lines of output
â "done!" is line #1
â "result: 2" is line #2
â OK » 6 honored (0.197s)
I’m using test cases like this throughout my upcoming Programming Node.js book
to test output of some of the simple scripts.
Yes, I know you can get some amazingly expressive test cases in other
languages, but I dare people who say that JavaScript is any ugly language to
find fault with this bit of code.