Skip to content

Commit

Permalink
pattern matching is operational
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 5, 2010
1 parent 09e31cf commit d5b0d34
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/vows/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,40 @@ this.Suite.prototype = new(function () {
// so we know when the tests are over.
// We match the keys against `matcher`, to decide
// whether or not they should be included in the test.
// Any key, including assertion function keys can be matched.
// If a child matches, then the n parent topics must not be skipped.
(function count(tests, _match) {
var match = false;

Object.keys(tests).filter(function (k) {
var keys = Object.keys(tests).filter(function (k) {
return k !== 'topic';
}).forEach(function (key) {
});

for (var i = 0, key; i < keys.length; i++) {
key = keys[i];

// If the parent node, or this one matches.
match = _match || matcher.test(key);

if (typeof(tests[key]) === 'object') {
match = count(tests[key], match);
} else if (! match) {
tests[key]._skip = true;
}
});
}

// If any of the children matched,
// don't skip this node.
for (var i = 0; i < keys.length; i++) {
if (! tests[keys[i]]._skip) { match = true }
}

if (match) { batch.remaining ++ }
else { tests._skip = true }

return match;
})(tests, false);

batch._remaining = batch.remaining;
};

Expand Down

0 comments on commit d5b0d34

Please sign in to comment.