Ensure a _.range result can start with -0.

This commit is contained in:
John-David Dalton
2015-10-21 22:05:29 -07:00
parent 5ec6f1085a
commit 8982578edd
2 changed files with 11 additions and 1 deletions

View File

@@ -12455,9 +12455,12 @@
if (step && isIterateeCall(start, end, step)) {
end = step = undefined;
}
start = +start || 0;
start = +start;
step = step === undefined ? 1 : (+step || 0);
if (start !== start) {
start = 0;
}
if (end === undefined) {
end = start;
start = 0;

View File

@@ -14911,6 +14911,13 @@
assert.deepEqual(_.range(21, 10, -3), [21, 18, 15, 12]);
});
QUnit.test('should not coerce `start` of `-0` to `0`', function(assert) {
assert.expect(1);
var actual = _.range(-0, 1);
assert.strictEqual(1 / actual[0], -Infinity);
});
QUnit.test('should treat falsey `start` arguments as `0`', function(assert) {
assert.expect(13);