test262
test262 copied to clipboard
built-ins/TypedArray/prototype/map/callbackfn-resize.js seems wrong
In this part:
result = sample.map(function(element, index, array) {
if (elements.length === 0) {
try {
buffer.resize(2 * BPE);
finalElement = undefined;
finalResult = NaNvalue;
...
} catch (_) {
...
}
}
elements.push(element);
indices.push(index);
arrays.push(array);
return index; <<<< here
});
The callback function which we pass as a parameter to map() always returns index, however, we expect the result to be:
assert.compareArray(result, [0, 1, finalResult], 'result (shrink)');
This doesn't seem right. Shouldn't we do:
assert.compareArray(result, [0, 1, 2], 'result (shrink)');
instead?
cc @syg
My reading of that test agrees with @marjakh's reading.
Since result is the result of calling TypedArray.prototype.map, it's a new TA backed by a different buffer. The comparison to [0, 1, finalResult] makes me think the test writer maybe was trying to test sample after it shrunk? But that doesn't really make sense either since I don't know where 1 and 2 would come from...
cc @sarahghp
@marjakh lets also add @Ms2ger @romulocintra @ryzokuken
Resolved via gh-3721.