Implement Iterator.range method
Categories
(Core :: JavaScript: Standard Library, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox135 | --- | fixed |
People
(Reporter: dminor, Assigned: sarahngima77)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
The Iterator.range
method itself is quite simple, it just delegates to another function, called CreateNumericRangeIterator
. As a starting point, let's add a CreateNumericRangeIterator
method that returns false, and call it from Iterator.range
. For the last parameter type
, let's make it a boolean called isNumberRange
, and use true
for NUMBER-RANGE
and false
for BIGINT-RANGE
.
You can use typeof
to figure out the types of the arguments, and ThrowTypeError
to throw if start is not a number, but you'll first need to add a new error message to the bottom of ErrorNumbers.msg.
Please include the specification steps in the function implementation, there's already examples of how to format this in Iterator.js
Instead of having it in it's own #ifdef NIGHTLY_BUILD
block at the top of the file, please move everything down into the larger #ifdef NIGHTLY_BUILD
block at the bottom of the file, right underneath IteratorZipKeyed
.
There's also a mistake in Iteratation.cpp, the number of arguments for Iterator.range should be 3 instead of 1. This needs to be fixed first, or you'll see assertions in debug builds when you attempt to use Iterator.range
.
Reporter | ||
Comment 1•2 months ago
|
||
Finally, let's add a new file for Iterator.range
tests under js/src/tests/non262/Iterator/range.js
. Eventually we're planning to upstream our tests to Test262, but for now, let's use something local. You can write some tests to make sure Iterator.range
throws when given something other than a number or bigint.
Reporter | ||
Updated•2 months ago
|
Assignee | ||
Comment 2•2 months ago
|
||
Updated•2 months ago
|
Updated•2 months ago
|
Description
•