Add tests for -0 keys.

This commit is contained in:
John-David Dalton
2016-04-18 22:54:31 -07:00
parent 5283b0f407
commit ad27b62343

View File

@@ -7247,6 +7247,20 @@
});
});
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
assert.expect(1);
var object = { '-0': 'a', '0': 'b' },
props = [-0, Object(-0), 0, Object(0)],
expected = lodashStable.map(props, alwaysTrue);
var actual = lodashStable.map(props, function(key) {
return func(object, key);
});
assert.deepEqual(actual, expected);
});
QUnit.test('`_.' + methodName + '` should work with a symbol `path`', function(assert) {
assert.expect(1);
@@ -18714,6 +18728,20 @@
});
});
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
assert.expect(1);
var object = { '-0': 'a', '0': 'b' },
props = [-0, Object(-0), 0, Object(0)],
expected = ['a', 'a', 'b', 'b'];
var actual = lodashStable.map(props, function(key) {
return func(object, key);
});
assert.deepEqual(actual, expected);
});
QUnit.test('`_.' + methodName + '` should get symbol keyed property values', function(assert) {
assert.expect(1);
@@ -19131,7 +19159,7 @@
assert.deepEqual(actual, NaN);
});
QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) {
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
assert.expect(1);
var values = [[0], [-0], ['0'], ['-0'], [0, 1], [-0, 1], ['0', 1], ['-0', 1]],
@@ -20582,7 +20610,7 @@
assert.strictEqual(func(undefined, 4), 4);
});
QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) {
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
assert.expect(2);
var values = [0, '0', -0, '-0'],
@@ -22648,7 +22676,7 @@
lodashStable.each(['toInteger', 'toNumber', 'toSafeInteger'], function(methodName) {
var func = _[methodName];
QUnit.test('`_.' + methodName + '` should preserve sign of `0`', function(assert) {
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
assert.expect(2);
var values = [0, '0', -0, '-0'],
@@ -23084,11 +23112,11 @@
assert.deepEqual(actual, expected);
});
QUnit.test('should preserve sign of `0`', function(assert) {
QUnit.test('should preserve the sign of `0`', function(assert) {
assert.expect(1);
var values = [0, Object(0), -0, Object(-0)],
expected = ['0', '0', '-0', '-0'],
var values = [-0, Object(-0), 0, Object(0)],
expected = ['-0', '-0', '0', '0'],
actual = lodashStable.map(values, _.toString);
assert.deepEqual(actual, expected);
@@ -24048,6 +24076,37 @@
});
});
QUnit.test('should preserve the sign of `0`', function(assert) {
assert.expect(1);
var negExp = [true, { '0': 'b' }],
posExp = [true, { '-0': 'a' }],
expected = [negExp, negExp, posExp, posExp],
props = [-0, Object(-0), 0, Object(0)];
var actual = lodashStable.map(props, function(key) {
var object = { '-0': 'a', '0': 'b' };
return [_.unset(object, key), object];
});
assert.deepEqual(actual, expected);
});
QUnit.test('should unset symbol keyed property values', function(assert) {
assert.expect(2);
if (Symbol) {
var object = {};
object[symbol] = 1;
assert.strictEqual(_.unset(object, symbol), true);
assert.notOk(symbol in object);
}
else {
skipAssert(assert, 2);
}
});
QUnit.test('should unset deep property values', function(assert) {
assert.expect(4);