Rename _.conj, _.disj, and _.juxt to _.overEvery, _.overSome, and _.over.

This commit is contained in:
John-David Dalton
2015-11-18 16:05:25 -08:00
parent 44397f79a6
commit b9f2855034
2 changed files with 353 additions and 353 deletions

View File

@@ -2757,95 +2757,6 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.conj');
(function() {
QUnit.test('should create a function that returns `true` if all predicates return truthy', function(assert) {
assert.expect(1);
var conjed = _.conj(lodashStable.constant(true), lodashStable.constant(1), lodashStable.constant('a'));
assert.strictEqual(conjed(), true);
});
QUnit.test('should return `false` as soon as a predicate returns falsey', function(assert) {
assert.expect(2);
var count = 0,
falsey = function() { count++; return false; },
truthy = function() { count++; return true; },
conjed = _.conj(truthy, falsey, truthy);
assert.strictEqual(conjed(), false);
assert.strictEqual(count, 2);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(2);
var conjed = _.conj(undefined, null);
assert.strictEqual(conjed(true), true);
assert.strictEqual(conjed(false), false);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
conjed = _.conj('a', 'c');
assert.strictEqual(conjed(object), false);
conjed = _.conj('b', 'a');
assert.strictEqual(conjed(object), true);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
conjed = _.conj({ 'b': 2 }, { 'a': 1 });
assert.strictEqual(conjed(object), true);
conjed = _.conj({ 'a': 1 }, { 'c': 3 });
assert.strictEqual(conjed(object), false);
});
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var conjed = _.conj(lodashStable.constant(true), [lodashStable.constant(false)]);
assert.strictEqual(conjed(), false);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var args;
var conjed = _.conj(function() {
args = slice.call(arguments);
});
conjed('a', 'b', 'c');
assert.deepEqual(args, ['a', 'b', 'c']);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(2);
var conjed = _.conj(function() { return this.b; }, function() { return this.a; }),
object = { 'conjed': conjed, 'a': 1, 'b': 2 };
assert.strictEqual(object.conjed(), true);
object.a = 0;
assert.strictEqual(object.conjed(), false);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.constant');
(function() {
@@ -4093,108 +4004,6 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.disj');
(function() {
QUnit.test('should create a function that returns `true` if any predicates return truthy', function(assert) {
assert.expect(2);
var disjed = _.disj(lodashStable.constant(false), lodashStable.constant(1), lodashStable.constant(''));
assert.strictEqual(disjed(), true);
disjed = _.disj(lodashStable.constant(null), lodashStable.constant('a'), lodashStable.constant(0));
assert.strictEqual(disjed(), true);
});
QUnit.test('should return `true` as soon as `predicate` returns truthy', function(assert) {
assert.expect(2);
var count = 0,
falsey = function() { count++; return false; },
truthy = function() { count++; return true; },
disjed = _.disj(falsey, truthy, falsey);
assert.strictEqual(disjed(), true);
assert.strictEqual(count, 2);
});
QUnit.test('should return `false` if all predicates return falsey', function(assert) {
assert.expect(2);
var disjed = _.disj(lodashStable.constant(false), lodashStable.constant(false), lodashStable.constant(false));
assert.strictEqual(disjed(), false);
disjed = _.disj(lodashStable.constant(null), lodashStable.constant(0), lodashStable.constant(''));
assert.strictEqual(disjed(), false);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(2);
var disjed = _.disj(undefined, null);
assert.strictEqual(disjed(true), true);
assert.strictEqual(disjed(false), false);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
disjed = _.disj('c', 'a');
assert.strictEqual(disjed(object), true);
disjed = _.disj('d', 'c');
assert.strictEqual(disjed(object), false);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
disjed = _.disj({ 'c': 3 }, { 'a': 1 });
assert.strictEqual(disjed(object), true);
disjed = _.disj({ 'b': 1 }, { 'a': 2 });
assert.strictEqual(disjed(object), false);
});
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var disjed = _.disj(lodashStable.constant(false), [lodashStable.constant(true)]);
assert.strictEqual(disjed(), true);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var args;
var disjed = _.disj(function() {
args = slice.call(arguments);
});
disjed('a', 'b', 'c');
assert.deepEqual(args, ['a', 'b', 'c']);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(2);
var disjed = _.disj(function() { return this.b; }, function() { return this.a; }),
object = { 'disjed': disjed, 'a': 1, 'b': 2 };
assert.strictEqual(object.disjed(), true);
object.a = object.b = 0;
assert.strictEqual(object.disjed(), false);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.drop');
(function() {
@@ -11241,63 +11050,6 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.juxt');
(function() {
QUnit.test('should create a function that invokes `iteratees`', function(assert) {
assert.expect(1);
var juxted = _.juxt(Math.max, Math.min);
assert.deepEqual(juxted(1, 2, 3, 4), [4, 1]);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(1);
var juxted = _.juxt(undefined, null);
assert.deepEqual(juxted('a', 'b', 'c'), ['a', 'a']);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(1);
var object = { 'a': 1, 'b': 2 },
juxted = _.juxt('b', 'a');
assert.deepEqual(juxted(object), [2, 1]);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(1);
var object = { 'a': 1, 'b': 2 },
juxted = _.juxt({ 'c': 3 }, { 'a': 1 });
assert.deepEqual(juxted(object), [false, true]);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var juxted = _.juxt(function() {
return slice.call(arguments);
});
assert.deepEqual(juxted('a', 'b', 'c'), [['a', 'b', 'c']]);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(1);
var juxted = _.juxt(function() { return this.b; }, function() { return this.a; }),
object = { 'juxted': juxted, 'a': 1, 'b': 2 };
assert.deepEqual(object.juxted(), [2, 1]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.map');
(function() {
@@ -13996,6 +13748,254 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.over');
(function() {
QUnit.test('should create a function that invokes `iteratees`', function(assert) {
assert.expect(1);
var over = _.over(Math.max, Math.min);
assert.deepEqual(over(1, 2, 3, 4), [4, 1]);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(1);
var over = _.over(undefined, null);
assert.deepEqual(over('a', 'b', 'c'), ['a', 'a']);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(1);
var object = { 'a': 1, 'b': 2 },
over = _.over('b', 'a');
assert.deepEqual(over(object), [2, 1]);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(1);
var object = { 'a': 1, 'b': 2 },
over = _.over({ 'c': 3 }, { 'a': 1 });
assert.deepEqual(over(object), [false, true]);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var over = _.over(function() {
return slice.call(arguments);
});
assert.deepEqual(over('a', 'b', 'c'), [['a', 'b', 'c']]);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(1);
var over = _.over(function() { return this.b; }, function() { return this.a; }),
object = { 'over': over, 'a': 1, 'b': 2 };
assert.deepEqual(object.over(), [2, 1]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.overEvery');
(function() {
QUnit.test('should create a function that returns `true` if all predicates return truthy', function(assert) {
assert.expect(1);
var over = _.overEvery(lodashStable.constant(true), lodashStable.constant(1), lodashStable.constant('a'));
assert.strictEqual(over(), true);
});
QUnit.test('should return `false` as soon as a predicate returns falsey', function(assert) {
assert.expect(2);
var count = 0,
falsey = function() { count++; return false; },
truthy = function() { count++; return true; },
over = _.overEvery(truthy, falsey, truthy);
assert.strictEqual(over(), false);
assert.strictEqual(count, 2);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(2);
var over = _.overEvery(undefined, null);
assert.strictEqual(over(true), true);
assert.strictEqual(over(false), false);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
over = _.overEvery('a', 'c');
assert.strictEqual(over(object), false);
over = _.overEvery('b', 'a');
assert.strictEqual(over(object), true);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
over = _.overEvery({ 'b': 2 }, { 'a': 1 });
assert.strictEqual(over(object), true);
over = _.overEvery({ 'a': 1 }, { 'c': 3 });
assert.strictEqual(over(object), false);
});
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var over = _.overEvery(lodashStable.constant(true), [lodashStable.constant(false)]);
assert.strictEqual(over(), false);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var args;
var over = _.overEvery(function() {
args = slice.call(arguments);
});
over('a', 'b', 'c');
assert.deepEqual(args, ['a', 'b', 'c']);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(2);
var over = _.overEvery(function() { return this.b; }, function() { return this.a; }),
object = { 'over': over, 'a': 1, 'b': 2 };
assert.strictEqual(object.over(), true);
object.a = 0;
assert.strictEqual(object.over(), false);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.overSome');
(function() {
QUnit.test('should create a function that returns `true` if any predicates return truthy', function(assert) {
assert.expect(2);
var over = _.overSome(lodashStable.constant(false), lodashStable.constant(1), lodashStable.constant(''));
assert.strictEqual(over(), true);
over = _.overSome(lodashStable.constant(null), lodashStable.constant('a'), lodashStable.constant(0));
assert.strictEqual(over(), true);
});
QUnit.test('should return `true` as soon as `predicate` returns truthy', function(assert) {
assert.expect(2);
var count = 0,
falsey = function() { count++; return false; },
truthy = function() { count++; return true; },
over = _.overSome(falsey, truthy, falsey);
assert.strictEqual(over(), true);
assert.strictEqual(count, 2);
});
QUnit.test('should return `false` if all predicates return falsey', function(assert) {
assert.expect(2);
var over = _.overSome(lodashStable.constant(false), lodashStable.constant(false), lodashStable.constant(false));
assert.strictEqual(over(), false);
over = _.overSome(lodashStable.constant(null), lodashStable.constant(0), lodashStable.constant(''));
assert.strictEqual(over(), false);
});
QUnit.test('should use `_.identity` when a predicate is nullish', function(assert) {
assert.expect(2);
var over = _.overSome(undefined, null);
assert.strictEqual(over(true), true);
assert.strictEqual(over(false), false);
});
QUnit.test('should work with a "_.property" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
over = _.overSome('c', 'a');
assert.strictEqual(over(object), true);
over = _.overSome('d', 'c');
assert.strictEqual(over(object), false);
});
QUnit.test('should work with a "_.matches" style predicate', function(assert) {
assert.expect(2);
var object = { 'a': 1, 'b': 2 },
over = _.overSome({ 'c': 3 }, { 'a': 1 });
assert.strictEqual(over(object), true);
over = _.overSome({ 'b': 1 }, { 'a': 2 });
assert.strictEqual(over(object), false);
});
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var over = _.overSome(lodashStable.constant(false), [lodashStable.constant(true)]);
assert.strictEqual(over(), true);
});
QUnit.test('should provide multiple arguments to predicates', function(assert) {
assert.expect(1);
var args;
var over = _.overSome(function() {
args = slice.call(arguments);
});
over('a', 'b', 'c');
assert.deepEqual(args, ['a', 'b', 'c']);
});
QUnit.test('should not set a `this` binding', function(assert) {
assert.expect(2);
var over = _.overSome(function() { return this.b; }, function() { return this.a; }),
object = { 'over': over, 'a': 1, 'b': 2 };
assert.strictEqual(object.over(), true);
object.a = object.b = 0;
assert.strictEqual(object.over(), false);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.pad');
(function() {
@@ -22605,7 +22605,7 @@
func = _[methodName];
var actual = lodashStable.map(falsey, function(value, index) {
var pass = !index && /^(?:backflow|compose|conj|disj|flow(Right)?)$/.test(methodName);
var pass = !index && /^(?:backflow|compose|flow(Right)?|over(?:Every|Some)?)$/.test(methodName);
try {
index ? func(value) : func();