                                              '      \tprog (--help | -h)'
 
             usage = 'Usage:\n' +
-                    '  prog <a> <b> <c>\n' + 
+                    '  prog <a> <b> <c>\n' +
                     '  prog --version\n'   +
                     '  prog (--help | -h)\n\n'
             eq printable_usage(usage, 'rn'), 'Usage:\n' +

            eq printable_usage(usage, null), 'usage: nospace'


    `}`

    print '================================================================'

    passes = 0
    errors = []
    for test of tests
        try
            tests[test]()
            passes += 1
            process.stdout.write '.'
        catch e
            errors.push([test, e])
            process.stdout.write 'F'
    print ''

    for [test, e] in errors
        print "In test #{test}, #{e.message}"

    print "#{passes} successes, #{errors.length} failures"
    print '================================================================'
)(require './docopt')

print = () -> console.log.apply @, [].slice.call(arguments)
eq = (a, b) ->
    as = a.toString()
    bs = b.toString()
    if as == bs then return else throw new Error "#{as} != #{bs}"

(() ->
    [setup, teardown, clear] = (() ->
        buffer = ''
        cl = console.log
        psw = process.stdout.write
        [() ->
            console.log = () ->
                buffer += ([].slice.call arguments).join() + '\n'
            process.stdout.write = () ->
                buffer += ([].slice.call arguments).join()
            null

        () ->
             console.log = cl
             process.stdout.write = psw
             null

        () ->
            stdout = buffer
            buffer = ''
            stdout]
    )()

    `with (this) //`
    tests =
        test_opt_parse: ->
            eq Option.parse('-h'), new Option('-h', null)
            eq Option.parse('-h'), new Option('-h', null)
