test262 icon indicating copy to clipboard operation
test262 copied to clipboard

built-ins/TypedArray/prototype/map/callbackfn-resize.js seems wrong

Open marjakh opened this issue 3 years ago • 3 comments

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

marjakh avatar Jan 21 '22 11:01 marjakh

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...

syg avatar Jan 21 '22 16:01 syg

cc @sarahghp

marjakh avatar Jan 24 '22 12:01 marjakh

@marjakh lets also add @Ms2ger @romulocintra @ryzokuken

rwaldron avatar Jan 24 '22 18:01 rwaldron

Resolved via gh-3721.

jugglinmike avatar Nov 18 '22 19:11 jugglinmike