Skip to content

Commit

Permalink
Bind all test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua T Corbin authored and James Halliday committed May 14, 2014
1 parent f9774cc commit 1ca29e2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/test.js
Expand Up @@ -36,10 +36,8 @@ var getTestArgs = function (name_, opts_, cb_) {
};

function Test (name_, opts_, cb_) {
var self = this;

var args = getTestArgs(name_, opts_, cb_);

this.readable = true;
this.name = args.name || '(anonymous)';
this.assertCount = 0;
Expand All @@ -49,9 +47,18 @@ function Test (name_, opts_, cb_) {
this._cb = args.cb;
this._progeny = [];
this._ok = true;
this.end = function () {
return Test.prototype.end.apply(self, arguments);
};

for (prop in this) {
this[prop] = (function bind(self, val) {
if (typeof val === 'function') {
return function bound() {
return val.apply(self, arguments);
};
} else {
return val;
}
})(this, this[prop]);
}
}

Test.prototype.run = function () {
Expand Down

0 comments on commit 1ca29e2

Please sign in to comment.