mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Add _.difference and _.intersection tests for -0.
This commit is contained in:
115
test/test.js
115
test/test.js
@@ -4722,6 +4722,19 @@
|
||||
assert.deepEqual(actual, [1, 3]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should treat `-0` and `0` as the same value', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [-0, 0],
|
||||
expected = lodashStable.map(values, alwaysEmptyArray);
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return func(values, [value]);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should match `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -4743,6 +4756,27 @@
|
||||
assert.deepEqual(func(array1, array2), [LARGE_ARRAY_SIZE]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `-0` and `0`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [-0, 0],
|
||||
expected = lodashStable.map(values, alwaysEmptyArray);
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(value));
|
||||
return func(values, largeArray);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN);
|
||||
assert.deepEqual(func([1, NaN, 3], largeArray), [1, 3]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of objects', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -4753,17 +4787,11 @@
|
||||
assert.deepEqual(func([object1, object2], largeArray), [object2]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN);
|
||||
assert.deepEqual(func([1, NaN, 3], largeArray), [1, 3]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should ignore values that are not array-like', function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var array = [1, null, 3];
|
||||
|
||||
assert.deepEqual(func(args, 3, { '0': 1 }), [1, 2, 3]);
|
||||
assert.deepEqual(func(null, array, 1), []);
|
||||
assert.deepEqual(func(array, args, null), [null]);
|
||||
@@ -7926,28 +7954,11 @@
|
||||
assert.deepEqual(actual, [1, 2]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should match `NaN`', function(assert) {
|
||||
QUnit.test('`_.' + methodName + '` should work with a single array', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var actual = func([1, NaN, 3], [NaN, 5, NaN]);
|
||||
assert.deepEqual(actual, [NaN]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of objects', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = {},
|
||||
largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(object));
|
||||
|
||||
assert.deepEqual(func([object], largeArray), [object]);
|
||||
assert.deepEqual(func(lodashStable.range(LARGE_ARRAY_SIZE), [1]), [1]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN);
|
||||
assert.deepEqual(func([1, NaN, 3], largeArray), [NaN]);
|
||||
var actual = func([1, 1, 3, 2, 2]);
|
||||
assert.deepEqual(actual, [1, 3, 2]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with `arguments` objects', function(assert) {
|
||||
@@ -7960,11 +7971,55 @@
|
||||
assert.deepEqual(func(args, array), expected);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with a single array', function(assert) {
|
||||
QUnit.test('`_.' + methodName + '` should treat `-0` and `0` as the same value', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var actual = func([1, 1, 3, 2, 2]);
|
||||
assert.deepEqual(actual, [1, 3, 2]);
|
||||
var values = [-0, 0],
|
||||
expected = lodashStable.map(values, lodashStable.constant(['-0']));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return lodashStable.map(func(values, [value]), lodashStable.toString);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should match `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var actual = func([1, NaN, 3], [NaN, 5, NaN]);
|
||||
assert.deepEqual(actual, [NaN]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `-0` and `0`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [-0, 0],
|
||||
expected = lodashStable.map(values, lodashStable.constant(['-0']));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(value));
|
||||
return lodashStable.map(func(values, largeArray), lodashStable.toString);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of `NaN`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var largeArray = lodashStable.times(LARGE_ARRAY_SIZE, alwaysNaN);
|
||||
assert.deepEqual(func([1, NaN, 3], largeArray), [NaN]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with large arrays of objects', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var object = {},
|
||||
largeArray = lodashStable.times(LARGE_ARRAY_SIZE, lodashStable.constant(object));
|
||||
|
||||
assert.deepEqual(func([object], largeArray), [object]);
|
||||
assert.deepEqual(func(lodashStable.range(LARGE_ARRAY_SIZE), [1]), [1]);
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should treat values that are not arrays or `arguments` objects as empty', function(assert) {
|
||||
|
||||
Reference in New Issue
Block a user