The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Elegantly Simple

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Travis Swicegood

Posts: 191
Nickname: tswicegood
Registered: Dec, 2008

Travis Swicegood is AppDev @ Ning and author of Pragmatic Version Control using Git
Elegantly Simple Posted: Oct 24, 2011 8:10 PM
Reply to this message Reply

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.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Travis Swicegood
Latest Posts From Travis Swicegood

Advertisement

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:

vows.describe("output generated by").addBatch(
  expectedOutput("sync-add.js", [
    "result: 2",
    "done!"
  ])
).addBatch(
  expectedOutput("async-add.js", [
    "done!",
    "result: 2"
  ])
).export(module);

It generates this output when run with --spec:

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.

Read: Elegantly Simple

Topic: Evolutionary Design Illustrated Previous Topic   Next Topic Topic: ThoughtWorks Agile East

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use