Skip to content

Commit

Permalink
Use official names instead of aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
gyeates committed Jun 20, 2014
1 parent dd23ee6 commit 600f997
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions test/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
equal(result, 2, 'found the first "2" and broke the loop');
});

test('find', function() {
test('detect', function() {
strictEqual(_.detect, _.find, 'alias for detect');
});

Expand Down Expand Up @@ -243,61 +243,61 @@
deepEqual(_.reject(list, []), [], 'Returns empty list given empty array');
});

test('all', function() {
ok(_.all([], _.identity), 'the empty set');
ok(_.all([true, true, true], _.identity), 'all true values');
ok(!_.all([true, false, true], _.identity), 'one false value');
ok(_.all([0, 10, 28], function(num){ return num % 2 == 0; }), 'even numbers');
ok(!_.all([0, 11, 28], function(num){ return num % 2 == 0; }), 'an odd number');
ok(_.all([1], _.identity) === true, 'cast to boolean - true');
ok(_.all([0], _.identity) === false, 'cast to boolean - false');
ok(!_.all([undefined, undefined, undefined], _.identity), 'works with arrays of undefined');
test('every', function() {
ok(_.every([], _.identity), 'the empty set');
ok(_.every([true, true, true], _.identity), 'every true values');
ok(!_.every([true, false, true], _.identity), 'one false value');
ok(_.every([0, 10, 28], function(num){ return num % 2 == 0; }), 'even numbers');
ok(!_.every([0, 11, 28], function(num){ return num % 2 == 0; }), 'an odd number');
ok(_.every([1], _.identity) === true, 'cast to boolean - true');
ok(_.every([0], _.identity) === false, 'cast to boolean - false');
ok(!_.every([undefined, undefined, undefined], _.identity), 'works with arrays of undefined');

var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}];
ok(!_.all(list, {a: 1, b: 2}), 'Can be called with object');
ok(_.all(list, 'a'), 'String mapped to object property');
ok(!_.every(list, {a: 1, b: 2}), 'Can be called with object');
ok(_.every(list, 'a'), 'String mapped to object property');

list = [{a: 1, b: 2}, {a: 2, b: 2, c: true}];
ok(_.all(list, {b: 2}), 'Can be called with object');
ok(!_.all(list, 'c'), 'String mapped to object property');
ok(_.every(list, {b: 2}), 'Can be called with object');
ok(!_.every(list, 'c'), 'String mapped to object property');

ok(_.all({a: 1, b: 2, c: 3, d: 4}, _.isNumber), 'takes objects');
ok(!_.all({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects');
ok(_.all(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(!_.all(['a', 'b', 'c', 'd', 'f'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(_.every({a: 1, b: 2, c: 3, d: 4}, _.isNumber), 'takes objects');
ok(!_.every({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects');
ok(_.every(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(!_.every(['a', 'b', 'c', 'd', 'f'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
});

test('every', function() {
test('all', function() {
strictEqual(_.all, _.every, 'alias for all');
});

test('any', function() {
ok(!_.any([]), 'the empty set');
ok(!_.any([false, false, false]), 'all false values');
ok(_.any([false, false, true]), 'one true value');
ok(_.any([null, 0, 'yes', false]), 'a string');
ok(!_.any([null, 0, '', false]), 'falsy values');
ok(!_.any([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers');
ok(_.any([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number');
ok(_.any([1], _.identity) === true, 'cast to boolean - true');
ok(_.any([0], _.identity) === false, 'cast to boolean - false');
ok(_.any([false, false, true]));
test('some', function() {
ok(!_.some([]), 'the empty set');
ok(!_.some([false, false, false]), 'all false values');
ok(_.some([false, false, true]), 'one true value');
ok(_.some([null, 0, 'yes', false]), 'a string');
ok(!_.some([null, 0, '', false]), 'falsy values');
ok(!_.some([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers');
ok(_.some([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number');
ok(_.some([1], _.identity) === true, 'cast to boolean - true');
ok(_.some([0], _.identity) === false, 'cast to boolean - false');
ok(_.some([false, false, true]));

var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}];
ok(!_.any(list, {a: 5, b: 2}), 'Can be called with object');
ok(_.any(list, 'a'), 'String mapped to object property');
ok(!_.some(list, {a: 5, b: 2}), 'Can be called with object');
ok(_.some(list, 'a'), 'String mapped to object property');

list = [{a: 1, b: 2}, {a: 2, b: 2, c: true}];
ok(_.any(list, {b: 2}), 'Can be called with object');
ok(!_.any(list, 'd'), 'String mapped to object property');
ok(_.some(list, {b: 2}), 'Can be called with object');
ok(!_.some(list, 'd'), 'String mapped to object property');

ok(_.any({a: '1', b: '2', c: '3', d: '4', e: 6}, _.isNumber), 'takes objects');
ok(!_.any({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects');
ok(_.any(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(!_.any(['x', 'y', 'z'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(_.some({a: '1', b: '2', c: '3', d: '4', e: 6}, _.isNumber), 'takes objects');
ok(!_.some({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects');
ok(_.some(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
ok(!_.some(['x', 'y', 'z'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works');
});

test('some', function() {
test('any', function() {
strictEqual(_.any, _.some, 'alias for any');
});

Expand Down

0 comments on commit 600f997

Please sign in to comment.