Skip to content

Commit

Permalink
Add assertions for fn matcher extra args
Browse files Browse the repository at this point in the history
9, 11, 13, 15 fail
  • Loading branch information
es128 committed Mar 27, 2015
1 parent b7b3ec2 commit 31fa47f
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,26 @@ describe('anymatch', function() {
});
it('should pass extra args to function matchers', function() {
matchers.push(function(string, arg1, arg2) { return arg1 || arg2; });
assert(!anymatch(matchers, 'bar.js'));
assert(!anymatch(matchers, ['bar.js', 0]));
assert(anymatch(matchers, ['bar.js', true]));
assert(anymatch(matchers, ['bar.js', 0, true]));
assert(!anymatch(matchers, 'bar.js'), 1);
assert(!anymatch(matchers, ['bar.js', 0]), 2);
assert(anymatch(matchers, ['bar.js', true]), 3);
assert(anymatch(matchers, ['bar.js', 0, true]), 4);
// with returnIndex
assert.equal(anymatch(matchers, ['bar.js', 1], true), 4, 5);
// curried versions
var matchFn1 = anymatch(matchers);
var matchFn2 = anymatch(matchers[4]);
assert(!matchFn1(['bar.js', 0]), 6);
assert(!matchFn2(['bar.js', 0]), 7);
assert(matchFn1(['bar.js', true]), 8);
assert(matchFn2(['bar.js', true]), 9);
assert(matchFn1(['bar.js', 0, true]), 10);
assert(matchFn2(['bar.js', 0, true]), 11);
// curried with returnIndex
assert.equal(matchFn1(['bar.js', 1], true), 4, 12);
assert.equal(matchFn2(['bar.js', 1], true), 0, 13);
assert.equal(matchFn1(['bar.js', 0], true), -1, 14);
assert.equal(matchFn2(['bar.js', 0], true), -1, 15);
matchers.pop();
});
});
Expand Down

0 comments on commit 31fa47f

Please sign in to comment.