var nodeunit = require('../lib/nodeunit');
var testCase = nodeunit.testCase;

exports.testTestCase = function (test) {
    test.expect(7);
    var call_order = [];
    var s = testCase({
        setUp: function () {
            call_order.push('setUp');
            test.equals(this.one, undefined);
            this.one = 1;
        },
        tearDown: function () {
            call_order.push('tearDown');
            test.ok(true, 'tearDown called');
        },
        test1: function (t) {
            call_order.push('test1');
            test.equals(this.one, 1);
            this.one = 2;
            t.done();
        },
        test2: function (t) {
            call_order.push('test2');
            test.equals(this.one, 1);
            t.done();
        }
    });
    nodeunit.runSuite(null, s, {}, function () {
        test.same(call_order, [
            'setUp', 'test1', 'tearDown',
            'setUp', 'test2', 'tearDown'
        ]);
        test.done();
    });
};

exports.tearDownAfterError = function (test) {
    test.expect(1);
    var s = testCase({
        tearDown: function () {
            test.ok(true, 'tearDown called');
        },
        test: function (t) {
            throw new Error('some error');
        }
    });
    nodeunit.runSuite(null, s, {}, function () {
        test.done();
    });
};

@@ -197,32 +197,33 @@
 etUp: function (
+t
 ) %7B%0A            
@@ -320,16 +320,38 @@
 ne = 1;%0A
+            t.done();%0A
         
@@ -373,32 +373,33 @@
 Down: function (
+t
 ) %7B%0A            
@@ -465,32 +465,54 @@
 rDown called');%0A
+            t.done();%0A
         %7D,%0A     
@@ -1136,32 +1136,33 @@
 Down: function (
+t
 ) %7B%0A            
@@ -1187,32 +1187,54 @@
 rDown called');%0A
+            t.done();%0A
         %7D,%0A     

change test-testcase to use new setUp/tearDown done() calls