mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Ensure a _.range result can start with -0.
This commit is contained in:
@@ -12455,9 +12455,12 @@
|
|||||||
if (step && isIterateeCall(start, end, step)) {
|
if (step && isIterateeCall(start, end, step)) {
|
||||||
end = step = undefined;
|
end = step = undefined;
|
||||||
}
|
}
|
||||||
start = +start || 0;
|
start = +start;
|
||||||
step = step === undefined ? 1 : (+step || 0);
|
step = step === undefined ? 1 : (+step || 0);
|
||||||
|
|
||||||
|
if (start !== start) {
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
if (end === undefined) {
|
if (end === undefined) {
|
||||||
end = start;
|
end = start;
|
||||||
start = 0;
|
start = 0;
|
||||||
|
|||||||
@@ -14911,6 +14911,13 @@
|
|||||||
assert.deepEqual(_.range(21, 10, -3), [21, 18, 15, 12]);
|
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) {
|
QUnit.test('should treat falsey `start` arguments as `0`', function(assert) {
|
||||||
assert.expect(13);
|
assert.expect(13);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user