Skip to content

Commit 3fa23eb

Browse files
committed
sync Iterator.range edge case with the proposal
1 parent 91d402d commit 3fa23eb

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- [`Iterator.range`](https://github.com/tc39/proposal-iterator.range) updated following the actual spec version
55
- Throw a `RangeError` on `NaN` `start` / `end` / `step`
66
- Allow `null` as `optionOrStep`
7-
- Fixed some other edge cases
87
- Improved accuracy of `Math.{ asinh, atanh }` polyfills with big and small values
98
- Wrap `Symbol.for` in `Symbol.prototype.description` polyfill for correct handling of empty string descriptions
109
- Fixed one more case (`Iterator.prototype.take`) of a V8 ~ Chromium < 126 [bug](https://issues.chromium.org/issues/336839115)

packages/core-js/internals/numeric-range-iterator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta
5252
if (step !== step || step === Infinity || step === -Infinity || (step === zero && start !== end)) {
5353
throw new $RangeError(INCORRECT_RANGE);
5454
}
55-
var hitsEnd = start === end || (end > start !== step > zero);
55+
var hitsEnd = end > start !== step > zero;
5656
setInternalState(this, {
5757
type: NUMERIC_RANGE_ITERATOR,
5858
start: start,

tests/unit-global/esnext.iterator.range.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ QUnit.test('Iterator.range', assert => {
3535
assert.deepEqual(from(range(0, 0)), []);
3636
assert.deepEqual(from(range(0, 0, { step: 1, inclusive: true })), []);
3737
assert.deepEqual(from(range(0, 0, -1)), [], 'start === end with negative step yields nothing');
38-
assert.deepEqual(from(range(0, 0, { step: -1, inclusive: true })), [], 'start === end with negative step inclusive yields nothing');
38+
assert.deepEqual(from(range(0, 0, { step: -1, inclusive: true })), [0], 'start === end with negative step inclusive yields start');
3939
assert.deepEqual(from(range(0, -5, 1)), []);
4040

4141
assert.throws(() => range(NaN, 0), RangeError, 'NaN as start');
@@ -104,7 +104,7 @@ QUnit.test('Iterator.range', assert => {
104104
assert.deepEqual(from(range(BigInt(0), BigInt(0))), []);
105105
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(1), inclusive: true })), []);
106106
assert.deepEqual(from(range(BigInt(0), BigInt(0), BigInt(-1))), [], 'BigInt: start === end with negative step yields nothing');
107-
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(-1), inclusive: true })), [], 'BigInt: start === end with negative step inclusive yields nothing');
107+
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(-1), inclusive: true })), [BigInt(0)], 'BigInt: start === end with negative step inclusive yields start');
108108
assert.deepEqual(from(range(BigInt(0), BigInt(-5), BigInt(1))), []);
109109

110110
iterator = range(BigInt(1), BigInt(3));

tests/unit-pure/esnext.iterator.range.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ QUnit.test('Iterator.range', assert => {
3434
assert.deepEqual(from(range(0, 0)), []);
3535
assert.deepEqual(from(range(0, 0, { step: 1, inclusive: true })), []);
3636
assert.deepEqual(from(range(0, 0, -1)), [], 'start === end with negative step yields nothing');
37-
assert.deepEqual(from(range(0, 0, { step: -1, inclusive: true })), [], 'start === end with negative step inclusive yields nothing');
37+
assert.deepEqual(from(range(0, 0, { step: -1, inclusive: true })), [0], 'start === end with negative step inclusive yields start');
3838
assert.deepEqual(from(range(0, -5, 1)), []);
3939

4040
assert.throws(() => range(NaN, 0), RangeError, 'NaN as start');
@@ -104,7 +104,7 @@ QUnit.test('Iterator.range', assert => {
104104
assert.deepEqual(from(range(BigInt(0), BigInt(0))), []);
105105
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(1), inclusive: true })), []);
106106
assert.deepEqual(from(range(BigInt(0), BigInt(0), BigInt(-1))), [], 'BigInt: start === end with negative step yields nothing');
107-
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(-1), inclusive: true })), [], 'BigInt: start === end with negative step inclusive yields nothing');
107+
assert.deepEqual(from(range(BigInt(0), BigInt(0), { step: BigInt(-1), inclusive: true })), [BigInt(0)], 'BigInt: start === end with negative step inclusive yields start');
108108
assert.deepEqual(from(range(BigInt(0), BigInt(-5), BigInt(1))), []);
109109

110110
iterator = range(BigInt(1), BigInt(3));

0 commit comments

Comments
 (0)