mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Add symbol tests for _.isObject and _.uniq.
This commit is contained in:
37
test/test.js
37
test/test.js
@@ -54,6 +54,7 @@
|
|||||||
params = root.arguments,
|
params = root.arguments,
|
||||||
push = arrayProto.push,
|
push = arrayProto.push,
|
||||||
slice = arrayProto.slice,
|
slice = arrayProto.slice,
|
||||||
|
Symbol = root.Symbol,
|
||||||
system = root.system,
|
system = root.system,
|
||||||
Uint8Array = root.Uint8Array;
|
Uint8Array = root.Uint8Array;
|
||||||
|
|
||||||
@@ -8342,7 +8343,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should return `false` for non-objects', 1, function() {
|
test('should return `false` for non-objects', 1, function() {
|
||||||
var values = falsey.concat(true, 1, 'a'),
|
var symbol = (Symbol || noop)(),
|
||||||
|
values = falsey.concat(true, 1, 'a', symbol),
|
||||||
expected = _.map(values, _.constant(false));
|
expected = _.map(values, _.constant(false));
|
||||||
|
|
||||||
var actual = _.map(values, function(value, index) {
|
var actual = _.map(values, function(value, index) {
|
||||||
@@ -15005,29 +15007,40 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should work with large arrays', 1, function() {
|
test('should work with large arrays', 1, function() {
|
||||||
var object = {};
|
var largeArray = [],
|
||||||
|
expected = [0, 'a', {}],
|
||||||
|
count = Math.ceil(LARGE_ARRAY_SIZE / expected.length);
|
||||||
|
|
||||||
var largeArray = _.times(LARGE_ARRAY_SIZE, function(index) {
|
_.times(count, function() {
|
||||||
switch (index % 3) {
|
push.apply(largeArray, expected);
|
||||||
case 0: return 0;
|
|
||||||
case 1: return 'a';
|
|
||||||
case 2: return object;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
deepEqual(_.uniq(largeArray), [0, 'a', object]);
|
deepEqual(_.uniq(largeArray), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with large arrays of boolean, `NaN`, `null`, and `undefined` values', 1, function() {
|
test('should work with large arrays of boolean, `NaN`, `null`, and `undefined` values', 1, function() {
|
||||||
var array = [],
|
var largeArray = [],
|
||||||
expected = [true, false, NaN, null, undefined],
|
expected = [true, false, NaN, null, undefined],
|
||||||
count = Math.ceil(LARGE_ARRAY_SIZE / expected.length);
|
count = Math.ceil(LARGE_ARRAY_SIZE / expected.length);
|
||||||
|
|
||||||
_.times(count, function() {
|
_.times(count, function() {
|
||||||
push.apply(array, expected);
|
push.apply(largeArray, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
deepEqual(_.uniq(array), expected);
|
deepEqual(_.uniq(largeArray), expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should work with large arrays of symbols', 1, function() {
|
||||||
|
if (Symbol) {
|
||||||
|
var largeArray = _.times(LARGE_ARRAY_SIZE, function() {
|
||||||
|
return Symbol();
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(_.uniq(largeArray), largeArray);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should distinguish between numbers and numeric strings', 1, function() {
|
test('should distinguish between numbers and numeric strings', 1, function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user