Skip to content

Commit

Permalink
switches are weird
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 24, 2014
1 parent f9aa185 commit aae89ee
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,28 @@ var getTestArgs = function (name_, opts_, cb_) {
var name = '(anonymous)';
var opts = {};
var cb;

for (var i = 0; i < arguments.length; i++) {
switch (typeof arguments[i]) {
case 'string':
name = arguments[i];
break;
case 'object':
opts = arguments[i] || opts;
break;
case 'function':
cb = arguments[i];
var arg = arguments[i];
var t = typeof arg;
if (t === 'string') {
name = arg;
}
else if (t === 'object') {
opts = arg || opts;
}
else if (t === 'function') {
cb = arg;
}
}

return {
name: name,
opts: opts,
cb: cb
};
return { name: name, opts: opts, cb: 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 Down Expand Up @@ -83,13 +79,13 @@ Test.prototype.test = function (name, opts, cb) {
t.on('prerun', function () {
self.assertCount++;
})

if (!self._pendingAsserts()) {
nextTick(function () {
self._end();
});
}

nextTick(function() {
if (!self._plan && self.pendingCount == self._progeny.length) {
self._end();
Expand Down

1 comment on commit aae89ee

@ljharb
Copy link
Collaborator

@ljharb ljharb commented on aae89ee Mar 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANK YOU! yes switches are weird and i hate them

Please sign in to comment.