mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Add tests for matching NaN.
This commit is contained in:
27
test/test.js
27
test/test.js
@@ -1902,6 +1902,10 @@
|
|||||||
strictEqual(_.contains([3, 2, 1], 3, true), true);
|
strictEqual(_.contains([3, 2, 1], 3, true), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match `NaN`', 1, function() {
|
||||||
|
strictEqual(_.contains([1, NaN, 3], NaN), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should be aliased', 1, function() {
|
test('should be aliased', 1, function() {
|
||||||
strictEqual(_.include, _.contains);
|
strictEqual(_.include, _.contains);
|
||||||
});
|
});
|
||||||
@@ -2857,6 +2861,10 @@
|
|||||||
deepEqual(actual, [1, 3]);
|
deepEqual(actual, [1, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match `NaN`', 1, function() {
|
||||||
|
deepEqual(_.difference([1, NaN, 3], [NaN, 5, NaN]), [1, 3]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with large arrays', 1, function() {
|
test('should work with large arrays', 1, function() {
|
||||||
var array1 = _.range(LARGE_ARRAY_SIZE + 1),
|
var array1 = _.range(LARGE_ARRAY_SIZE + 1),
|
||||||
array2 = _.range(LARGE_ARRAY_SIZE),
|
array2 = _.range(LARGE_ARRAY_SIZE),
|
||||||
@@ -4793,6 +4801,10 @@
|
|||||||
deepEqual(_.intersection(array), [1, 3, 2]);
|
deepEqual(_.intersection(array), [1, 3, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match `NaN`', 1, function() {
|
||||||
|
deepEqual(_.intersection([1, NaN, 3], [NaN, 5, NaN]), [NaN]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with large arrays of objects', 1, function() {
|
test('should work with large arrays of objects', 1, function() {
|
||||||
var object = {},
|
var object = {},
|
||||||
largeArray = _.times(LARGE_ARRAY_SIZE, _.constant(object));
|
largeArray = _.times(LARGE_ARRAY_SIZE, _.constant(object));
|
||||||
@@ -6722,6 +6734,10 @@
|
|||||||
strictEqual(func(empty, undefined), -1);
|
strictEqual(func(empty, undefined), -1);
|
||||||
strictEqual(func(empty, undefined, true), -1);
|
strictEqual(func(empty, undefined, true), -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('`_.' + methodName + '` should match `NaN`', 1, function() {
|
||||||
|
strictEqual(func([1, NaN, 3], NaN), 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -8489,6 +8505,13 @@
|
|||||||
_.pull(array, undefined);
|
_.pull(array, undefined);
|
||||||
deepEqual(array, [1, 3]);
|
deepEqual(array, [1, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should match `NaN`', 1, function() {
|
||||||
|
var array = [1, NaN, 3, NaN];
|
||||||
|
|
||||||
|
_.pull(array, NaN);
|
||||||
|
deepEqual(array, [1, 3]);
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -11024,6 +11047,10 @@
|
|||||||
deepEqual(_.uniq(objects), objects);
|
deepEqual(_.uniq(objects), objects);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not treat `NaN` as uniq', 1, function() {
|
||||||
|
deepEqual(_.uniq([1, NaN, 3, NaN]), [1, NaN, 3]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with `isSorted`', 3, function() {
|
test('should work with `isSorted`', 3, function() {
|
||||||
var expected = [1, 2, 3];
|
var expected = [1, 2, 3];
|
||||||
deepEqual(_.uniq([1, 2, 3], true), expected);
|
deepEqual(_.uniq([1, 2, 3], true), expected);
|
||||||
|
|||||||
Reference in New Issue
Block a user