Closed Bug 927611 Opened 8 years ago Closed 8 years ago

Make assertIteratorResult stricter

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jorendorff, Unassigned)

Details

0. Wait for the change described in bug 907077 comment 78 thru 80 to land.

1. Change assertIteratorResult to use assertEq on both value and done.

2. Some tests will break because they're doing something like
    assertIteratorResult(it.next(), [1, 2], false);
   Change those to say:
    assertDeepEq(it.next(), {value: [1, 2], done: false});
I took a look at this since I was in the area, but TBH I don't see the point.  The change would currently go from:

  assertIteratorNext(it, [1, 2])

to

  assertDeepEq(it.next(), { values: [1, 2], done: false })

which to me is enough of a loss of readability to not be worth it.  I can imagine very few cases in which you would want to assertEq of an expected array result.  In those few cases it would seem better to unroll those assertEq cases into separate

  var res = iter.next();
  assertIteratorResult(res, [1, 2], false);
  assertEq(res.value, some_other_array_I_know_about_already);

I changed assertIteratorResult to do assertEq in the jstests and that worked fine.  In jit-tests I got a few failures:

    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-clear-iterators-1.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-clear-iterators-2.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-forEach.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-add-2.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-pairs-2.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-pairs-3.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-remove-3.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-remove-4.js
    /home/wingo/src/mozilla-central/js/src/jit-test/tests/collections/Map-iterator-remove-6.js

Most are about map results, where the result is a pair.  I don't plan to work more on this, FWIW.
Yeah, I'm not going to do this either.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.