Bug 924318 - More iterator test cleanups. r=jwalden
authorAndy Wingo <wingo@igalia.com>
Thu, 17 Oct 2013 12:56:34 +0200
changeset 165887 68149d83be3a99b09cebb690eb4377d01fa832ce
parent 165886 4d45af314d05377a5da7550b8cd25ae9163a0c98
child 165888 84cf5a56188eb202e7d267254aa210067ae9072c
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs924318
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924318 - More iterator test cleanups. r=jwalden
js/src/jit-test/lib/iteration.js
js/src/jit-test/tests/collections/Map-clear-iterators-1.js
js/src/jit-test/tests/collections/Map-clear-iterators-2.js
js/src/jit-test/tests/collections/Map-forEach.js
js/src/jit-test/tests/collections/Map-iterator-add-2.js
js/src/jit-test/tests/collections/Map-iterator-pairs-2.js
js/src/jit-test/tests/collections/Map-iterator-remove-3.js
js/src/jit-test/tests/collections/Map-iterator-remove-4.js
js/src/jit-test/tests/collections/Map-iterator-remove-6.js
js/src/jit-test/tests/collections/Map-iterators-3.js
js/src/jit-test/tests/collections/Map-values-2.js
js/src/jit-test/tests/collections/Set-clear-iterators-1.js
js/src/jit-test/tests/collections/Set-clear-iterators-2.js
js/src/jit-test/tests/collections/Set-clear-iterators-3.js
js/src/jit-test/tests/collections/Set-forEach.js
js/src/jit-test/tests/collections/Set-iterator-add-2.js
js/src/jit-test/tests/collections/Set-iterator-proxies-2.js
js/src/jit-test/tests/collections/Set-iterator-remove-3.js
js/src/jit-test/tests/collections/Set-iterator-remove-4.js
js/src/jit-test/tests/collections/Set-iterator-remove-6.js
js/src/jit-test/tests/collections/Set-values-2.js
js/src/jit-test/tests/collections/iterator-proto-surfaces.js
js/src/jit-test/tests/debug/Frame-onPop-star-generators-01.js
js/src/jit-test/tests/debug/Frame-onPop-star-generators-02.js
js/src/jit-test/tests/debug/resumption-06.js
js/src/jit-test/tests/for-of/array-iterator-changing.js
js/src/jit-test/tests/for-of/array-iterator-generic.js
js/src/jit-test/tests/for-of/array-iterator-growing-1.js
js/src/jit-test/tests/for-of/array-iterator-proxy.js
js/src/jit-test/tests/for-of/array-iterator-shrinking.js
js/src/jit-test/tests/for-of/manual-advance.js
js/src/jit-test/tests/for-of/next-3.js
js/src/jit-test/tests/for-of/string-iterator-generic.js
js/src/tests/ecma_6/Generators/delegating-yield-12.js
js/src/tests/ecma_6/Generators/delegating-yield-2.js
js/src/tests/ecma_6/Generators/delegating-yield-3.js
js/src/tests/ecma_6/Generators/delegating-yield-4.js
js/src/tests/ecma_6/Generators/iteration.js
js/src/tests/ecma_6/Generators/shell.js
--- a/js/src/jit-test/lib/iteration.js
+++ b/js/src/jit-test/lib/iteration.js
@@ -14,8 +14,20 @@ if (typeof assertIteratorResult === 'und
         var expectedProps = ['done', 'value'];
         var actualProps = Object.getOwnPropertyNames(result);
         actualProps.sort(), expectedProps.sort();
         assertDeepEq(actualProps, expectedProps);
         assertDeepEq(result.value, value);
         assertDeepEq(result.done, done);
     }
 }
+
+if (typeof assertIteratorNext === 'undefined') {
+    var assertIteratorNext = function assertIteratorNext(iter, value) {
+        assertIteratorResult(iter.next(), value, false);
+    }
+}
+
+if (typeof assertIteratorDone === 'undefined') {
+    var assertIteratorDone = function assertIteratorDone(iter, value) {
+        assertIteratorResult(iter.next(), value, true);
+    }
+}
--- a/js/src/jit-test/tests/collections/Map-clear-iterators-1.js
+++ b/js/src/jit-test/tests/collections/Map-clear-iterators-1.js
@@ -1,22 +1,22 @@
 // A Map iterator does not visit entries removed by clear().
 
 load(libdir + "iteration.js");
 
 var m = Map();
 var it = m[std_iterator]();
 m.clear();
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
 
 m = Map([["a", 1], ["b", 2], ["c", 3], ["d", 4]]);
 it = m[std_iterator]();
-assertIteratorResult(it.next(), ["a", 1], false);
+assertIteratorNext(it, ["a", 1]);
 m.clear();
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
 
 var log = "";
 m = Map([["a", 1], ["b", 2], ["c", 3], ["d", 4]]);
 for (var [k, v] of m) {
     log += k + v;
     if (k == "b")
         m.clear();
 }
--- a/js/src/jit-test/tests/collections/Map-clear-iterators-2.js
+++ b/js/src/jit-test/tests/collections/Map-clear-iterators-2.js
@@ -1,12 +1,12 @@
 // A Map iterator continues to visit entries added after a clear().
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var m = Map([["a", 1]]);
 var it = m[std_iterator]();
-assertIteratorResult(it.next(), ["a", 1], false);
+assertIteratorNext(it, ["a", 1]);
 m.clear();
 m.set("b", 2);
-assertIteratorResult(it.next(), ["b", 2], false);
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorNext(it, ["b", 2]);
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/collections/Map-forEach.js
+++ b/js/src/jit-test/tests/collections/Map-forEach.js
@@ -17,17 +17,17 @@ var initialMap = new Map([['a', 1], ['b'
 initialMap.forEach(callback);
 
 // test that both the Maps are equal and are in same order
 var iterator = initialMap[std_iterator]();
 var count = 0;
 for (var [k, v] of testMap) {
     assertEq(initialMap.has(k), true);
     assertEq(initialMap.get(k), testMap.get(k));
-    assertIteratorResult(iterator.next(), [k, testMap.get(k)], false);
+    assertIteratorNext(iterator, [k, testMap.get(k)]);
     count++;
 }
 
 //check both the Maps we have are equal in size
 assertEq(initialMap.size, testMap.size);
 assertEq(initialMap.size, count);
 
 var x = { abc: 'test'};
--- a/js/src/jit-test/tests/collections/Map-iterator-add-2.js
+++ b/js/src/jit-test/tests/collections/Map-iterator-add-2.js
@@ -1,10 +1,10 @@
 // A Map iterator does not iterate over new entries added after it throws StopIteration.
 
 load(libdir + "iteration.js");
 
 var map = Map();
 var iter0 = map[std_iterator](), iter1 = map[std_iterator]();
-assertIteratorResult(iter0.next(), undefined, true);  // closes iter0
+assertIteratorDone(iter0, undefined);  // closes iter0
 map.set(1, 2);
-assertIteratorResult(iter0.next(), undefined, true);  // already closed
-assertIteratorResult(iter1.next(), [1, 2], false);  // was not yet closed
+assertIteratorDone(iter0, undefined);  // already closed
+assertIteratorNext(iter1, [1, 2]);     // was not yet closed
--- a/js/src/jit-test/tests/collections/Map-iterator-pairs-2.js
+++ b/js/src/jit-test/tests/collections/Map-iterator-pairs-2.js
@@ -3,11 +3,11 @@
 load(libdir + "iteration.js");
 
 var map = Map([['a', 1], ['b', 2]]);
 var iter = map[std_iterator]();
 var a = iter.next(), b = iter.next();
 assertIteratorResult(a, ['a', 1], false);
 assertIteratorResult(b, ['b', 2], false);
 assertEq(a.value !== b.value, true);
-var a1 = map[std_iterator]().next();
-assertIteratorResult(a1, ['a', 1], false);
+var a1 = map[std_iterator]();
+assertIteratorNext(a1, ['a', 1]);
 assertEq(a.value !== a1.value, true);
--- a/js/src/jit-test/tests/collections/Map-iterator-remove-3.js
+++ b/js/src/jit-test/tests/collections/Map-iterator-remove-3.js
@@ -1,13 +1,13 @@
 // A map iterator can cope with removing the next entry, then the current entry.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var map = Map([['a', 0], ['b', 1], ['c', 2], ['d', 3]]);
 var iter = map[std_iterator]();
-assertIteratorResult(iter.next(), ['a', 0], false);
-assertIteratorResult(iter.next(), ['b', 1], false);
+assertIteratorNext(iter, ['a', 0]);
+assertIteratorNext(iter, ['b', 1]);
 map.delete('c');
 map.delete('b');
-assertIteratorResult(iter.next(), ['d', 3], false);
-assertIteratorResult(iter.next(), undefined, true);
+assertIteratorNext(iter, ['d', 3]);
+assertIteratorDone(iter, undefined);
--- a/js/src/jit-test/tests/collections/Map-iterator-remove-4.js
+++ b/js/src/jit-test/tests/collections/Map-iterator-remove-4.js
@@ -8,24 +8,24 @@ var SIZE = 7;
 for (var j = 0; j < SIZE; j++)
     map.set(j, j);
 
 // Make lots of iterators pointing to entry 2 of the map.
 var NITERS = 5;
 var iters = [];
 for (var i = 0; i < NITERS; i++) {
     var iter = map[std_iterator]();
-    assertIteratorResult(iter.next(), [0, 0], false);
-    assertIteratorResult(iter.next(), [1, 1], false);
+    assertIteratorNext(iter, [0, 0]);
+    assertIteratorNext(iter, [1, 1]);
     iters[i] = iter;
 }
 
 // Remove half of the map entries.
 for (var j = 0; j < SIZE; j += 2)
     map.delete(j);
 
 // Make sure all the iterators still work.
 for (var i = 0; i < NITERS; i++) {
     var iter = iters[i];
     for (var j = 3; j < SIZE; j += 2)
-        assertIteratorResult(iter.next(), [j, j], false);
-    assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, [j, j]);
+    assertIteratorDone(iter, undefined);
 }
--- a/js/src/jit-test/tests/collections/Map-iterator-remove-6.js
+++ b/js/src/jit-test/tests/collections/Map-iterator-remove-6.js
@@ -3,19 +3,19 @@
 // script.)
 
 load(libdir + "iteration.js");
 
 var map = Map();
 for (var i = 0; i < 32; i++)
     map.set(i, i);
 var iter = map[std_iterator]();
-assertIteratorResult(iter.next(), [0, 0], false);
+assertIteratorNext(iter, [0, 0]);
 for (var i = 0; i < 30; i++)
     map.delete(i);
 assertEq(map.size, 2);
 for (var i = 32; i < 100; i++)
     map.set(i, i);  // eventually triggers compaction
 
 for (var i = 30; i < 100; i++)
-    assertIteratorResult(iter.next(), [i, i], false);
+    assertIteratorNext(iter, [i, i]);
 
-assertIteratorResult(iter.next(), undefined, true);
+assertIteratorDone(iter, undefined);
--- a/js/src/jit-test/tests/collections/Map-iterators-3.js
+++ b/js/src/jit-test/tests/collections/Map-iterators-3.js
@@ -1,10 +1,10 @@
 // A closed Map iterator does not visit new entries added after a clear().
 
 load(libdir + "iteration.js");
 
 var m = Map();
 var it = m[std_iterator]();
-assertIteratorResult(it.next(), undefined, true);  // close the iterator
+assertIteratorDone(it, undefined);  // close the iterator
 m.clear();
 m.set("a", 1);
-assertIteratorResult(it.next(), undefined, true);  // iterator still closed
+assertIteratorDone(it, undefined);  // iterator still closed
--- a/js/src/jit-test/tests/collections/Map-values-2.js
+++ b/js/src/jit-test/tests/collections/Map-values-2.js
@@ -2,17 +2,17 @@
 // respectively, of each key-value pair in the map.
 
 load(libdir + "iteration.js");
 
 var data = [["one", 1], ["two", 2], ["three", 3], ["four", 4]];
 var m = Map(data);
 
 var ki = m.keys();
-assertIteratorResult(ki.next(), "one", false);
-assertIteratorResult(ki.next(), "two", false);
-assertIteratorResult(ki.next(), "three", false);
-assertIteratorResult(ki.next(), "four", false);
-assertIteratorResult(ki.next(), undefined, true);
+assertIteratorNext(ki, "one");
+assertIteratorNext(ki, "two");
+assertIteratorNext(ki, "three");
+assertIteratorNext(ki, "four");
+assertIteratorDone(ki, undefined);
 
 assertEq([k for (k of m.keys())].toSource(), ["one", "two", "three", "four"].toSource());
 assertEq([k for (k of m.values())].toSource(), [1, 2, 3, 4].toSource());
 assertEq([k for (k of m.entries())].toSource(), data.toSource());
--- a/js/src/jit-test/tests/collections/Set-clear-iterators-1.js
+++ b/js/src/jit-test/tests/collections/Set-clear-iterators-1.js
@@ -1,22 +1,22 @@
 // A Set iterator does not visit entries removed by clear().
 
 load(libdir + "iteration.js");
 
 var s = Set();
 var it = s[std_iterator]();
 s.clear();
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
 
 s = Set(["a", "b", "c", "d"]);
 it = s[std_iterator]();
-assertIteratorResult(it.next(), "a", false);
+assertIteratorNext(it, "a");
 s.clear();
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
 
 var log = "";
 s = Set(["a", "b", "c", "d"]);
 for (var v of s) {
     log += v;
     if (v == "b")
         s.clear();
 }
--- a/js/src/jit-test/tests/collections/Set-clear-iterators-2.js
+++ b/js/src/jit-test/tests/collections/Set-clear-iterators-2.js
@@ -1,11 +1,11 @@
 // A Set iterator continues to visit entries added after a clear().
 
 load(libdir + "iteration.js");
 
 var s = Set(["a"]);
 var it = s[std_iterator]();
-assertIteratorResult(it.next(), "a", false);
+assertIteratorNext(it, "a");
 s.clear();
 s.add("b");
-assertIteratorResult(it.next(), "b", false);
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorNext(it, "b");
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/collections/Set-clear-iterators-3.js
+++ b/js/src/jit-test/tests/collections/Set-clear-iterators-3.js
@@ -1,10 +1,10 @@
 // A closed Set iterator does not visit new entries added after a clear().
 
 load(libdir + "iteration.js");
 
 var s = Set();
 var it = s[std_iterator]();
-assertIteratorResult(it.next(), undefined, true);  // close the iterator
+assertIteratorDone(it, undefined);  // close the iterator
 s.clear();
 s.add("a");
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/collections/Set-forEach.js
+++ b/js/src/jit-test/tests/collections/Set-forEach.js
@@ -16,17 +16,17 @@ function callback(value, key, set) {
 var initialSet = new Set(['a', 1, undefined]);
 initialSet.forEach(callback);
 
 // test that both the Sets are equal and are in same order
 var iterator = initialSet[std_iterator]();
 var count = 0;
 for (var v of testSet) {
     assertEq(initialSet.has(v), true);
-    assertIteratorResult(iterator.next(), v, false);
+    assertIteratorNext(iterator, v);
     count++;
 }
 
 //check both the Sets we have are equal in size
 assertEq(initialSet.size, testSet.size);
 assertEq(initialSet.size, count);
 
 var x = { abc: 'test'};
--- a/js/src/jit-test/tests/collections/Set-iterator-add-2.js
+++ b/js/src/jit-test/tests/collections/Set-iterator-add-2.js
@@ -1,10 +1,10 @@
 // A Set iterator does not iterate over new entries added after it throws StopIteration.
 
 load(libdir + "iteration.js");
 
 var set = Set();
 var iter0 = set[std_iterator](), iter1 = set[std_iterator]();
-assertIteratorResult(iter0.next(), undefined, true);  // closes iter0
+assertIteratorDone(iter0, undefined);  // closes iter0
 set.add("x");
-assertIteratorResult(iter0.next(), undefined, true);  // already closed
-assertIteratorResult(iter1.next(), "x", false);  // was not yet closed
+assertIteratorDone(iter0, undefined);  // already closed
+assertIteratorNext(iter1, "x");  // was not yet closed
--- a/js/src/jit-test/tests/collections/Set-iterator-proxies-2.js
+++ b/js/src/jit-test/tests/collections/Set-iterator-proxies-2.js
@@ -4,17 +4,17 @@ load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var g = newGlobal();
 
 var iterator_fn = Set.prototype[std_iterator];
 assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
 assertThrowsInstanceOf(function () { iterator_fn.call(Map()); }, TypeError);
 var setw = g.eval("Set(['x', 'y'])");
-assertIteratorResult(iterator_fn.call(setw).next(), "x", false);
+assertIteratorNext(iterator_fn.call(setw), "x");
 
 var next_fn = Set()[std_iterator]().next;
 assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
 assertThrowsInstanceOf(function () { next_fn.call(Map()[std_iterator]()); }, TypeError);
 var iterw = setw[std_iterator]();
 assertIteratorResult(next_fn.call(iterw), "x", false);
 assertIteratorResult(next_fn.call(iterw), "y", false);
 assertIteratorResult(next_fn.call(iterw), undefined, true);
--- a/js/src/jit-test/tests/collections/Set-iterator-remove-3.js
+++ b/js/src/jit-test/tests/collections/Set-iterator-remove-3.js
@@ -1,12 +1,12 @@
 // A set iterator can cope with removing the next entry, then the current entry.
 
 load(libdir + "iteration.js");
 
 var set = Set("abcd");
 var iter = set[std_iterator]();
-assertIteratorResult(iter.next(), "a", false);
-assertIteratorResult(iter.next(), "b", false);
+assertIteratorNext(iter, "a");
+assertIteratorNext(iter, "b");
 set.delete("c");
 set.delete("b");
-assertIteratorResult(iter.next(), "d", false);
-assertIteratorResult(iter.next(), undefined, true);
+assertIteratorNext(iter, "d");
+assertIteratorDone(iter, undefined);
--- a/js/src/jit-test/tests/collections/Set-iterator-remove-4.js
+++ b/js/src/jit-test/tests/collections/Set-iterator-remove-4.js
@@ -8,24 +8,24 @@ var SIZE = 7;
 for (var j = 0; j < SIZE; j++)
     set.add(j);
 
 // Make lots of iterators pointing to entry 2 of the set.
 var NITERS = 5;
 var iters = [];
 for (var i = 0; i < NITERS; i++) {
     var iter = set[std_iterator]();
-    assertIteratorResult(iter.next(), 0, false);
-    assertIteratorResult(iter.next(), 1, false);
+    assertIteratorNext(iter, 0);
+    assertIteratorNext(iter, 1);
     iters[i] = iter;
 }
 
 // Remove half of the set entries.
 for (var j = 0; j < SIZE; j += 2)
     set.delete(j);
 
 // Make sure all the iterators still work.
 for (var i = 0; i < NITERS; i++) {
     var iter = iters[i];
     for (var j = 3; j < SIZE; j += 2)
-        assertIteratorResult(iter.next(), j, false);
-    assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, j);
+    assertIteratorDone(iter, undefined);
 }
--- a/js/src/jit-test/tests/collections/Set-iterator-remove-6.js
+++ b/js/src/jit-test/tests/collections/Set-iterator-remove-6.js
@@ -3,18 +3,18 @@
 // script.)
 
 load(libdir + "iteration.js");
 
 var set = Set();
 for (var i = 0; i < 32; i++)
     set.add(i);
 var iter = set[std_iterator]();
-assertIteratorResult(iter.next(), 0, false);
+assertIteratorNext(iter, 0);
 for (var i = 0; i < 30; i++)
     set.delete(i);
 assertEq(set.size, 2);
 for (var i = 32; i < 100; i++)
     set.add(i);  // eventually triggers compaction
 
 for (var i = 30; i < 100; i++)
-    assertIteratorResult(iter.next(), i, false);
-assertIteratorResult(iter.next(), undefined, true);
+    assertIteratorNext(iter, i);
+assertIteratorDone(iter, undefined);
--- a/js/src/jit-test/tests/collections/Set-values-2.js
+++ b/js/src/jit-test/tests/collections/Set-values-2.js
@@ -2,17 +2,17 @@
 // and set.entries() returns an iterator that yields pairs [e, e].
 
 load(libdir + "iteration.js");
 
 var data = [1, 2, 3, 4];
 var s = Set(data);
 
 var ki = s.keys();
-assertIteratorResult(ki.next(), 1, false);
-assertIteratorResult(ki.next(), 2, false);
-assertIteratorResult(ki.next(), 3, false);
-assertIteratorResult(ki.next(), 4, false);
-assertIteratorResult(ki.next(), undefined, true);
+assertIteratorNext(ki, 1);
+assertIteratorNext(ki, 2);
+assertIteratorNext(ki, 3);
+assertIteratorNext(ki, 4);
+assertIteratorDone(ki, undefined);
 
 assertEq([...s.keys()].toSource(), data.toSource());
 assertEq([...s.values()].toSource(), data.toSource());
 assertEq([...s.entries()].toSource(), [[1, 1], [2, 2], [3, 3], [4, 4]].toSource());
--- a/js/src/jit-test/tests/collections/iterator-proto-surfaces.js
+++ b/js/src/jit-test/tests/collections/iterator-proto-surfaces.js
@@ -10,14 +10,14 @@ function test(constructor) {
     assertDeepEq(names, [std_iterator, 'next']);
 
     var desc = Object.getOwnPropertyDescriptor(proto, 'next');
     assertEq(desc.configurable, true);
     assertEq(desc.enumerable, false);
     assertEq(desc.writable, true);
 
     assertEq(proto[std_iterator](), proto);
-    assertIteratorResult(proto.next(), undefined, true);
+    assertIteratorDone(proto, undefined);
 }
 
 //test(Array);
 test(Map);
 test(Set);
--- a/js/src/jit-test/tests/debug/Frame-onPop-star-generators-01.js
+++ b/js/src/jit-test/tests/debug/Frame-onPop-star-generators-01.js
@@ -12,9 +12,9 @@ dbg.onDebuggerStatement = function handl
     };
 };
 g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
 g.eval("var it = g();");
 var rv = gw.evalInGlobal("it.next();");
 assertEq(rv.throw, "fit");
 
 dbg.enabled = false;
-assertIteratorResult(g.it.next(), 1, false);
+assertIteratorNext(g.it, 1);
--- a/js/src/jit-test/tests/debug/Frame-onPop-star-generators-02.js
+++ b/js/src/jit-test/tests/debug/Frame-onPop-star-generators-02.js
@@ -11,9 +11,9 @@ dbg.onDebuggerStatement = function handl
         throw "fit";
     };
 };
 g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
 g.eval("var it = g();");
 assertEq(gw.evalInGlobal("it.next();"), null);
 
 dbg.enabled = false;
-assertIteratorResult(g.it.next(), 1, false);
+assertIteratorNext(g.it, 1);
--- a/js/src/jit-test/tests/debug/resumption-06.js
+++ b/js/src/jit-test/tests/debug/resumption-06.js
@@ -10,11 +10,11 @@ g.eval("var dbg = new Debugger(debuggeeG
        "dbg.onDebuggerStatement = function () { return {return: '!'}; };");
 
 function* gen() {
     yield '1';
     debugger;  // Force return here. The value is ignored.
     yield '2';
 }
 var iter = gen();
-assertIteratorResult(iter.next(), '1', false);
+assertIteratorNext(iter, '1');
 assertEq(iter.next(), '!');
 assertThrowsInstanceOf(iter.next.bind(iter), TypeError);
--- a/js/src/jit-test/tests/for-of/array-iterator-changing.js
+++ b/js/src/jit-test/tests/for-of/array-iterator-changing.js
@@ -2,12 +2,12 @@
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var arr = [0, 1, 2];
 var it = arr[std_iterator]();
 arr[0] = 1000;
 arr[2] = 2000;
-assertIteratorResult(it.next(), 1000, false);
-assertIteratorResult(it.next(), 1, false);
-assertIteratorResult(it.next(), 2000, false);
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorNext(it, 1000);
+assertIteratorNext(it, 1);
+assertIteratorNext(it, 2000);
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/for-of/array-iterator-generic.js
+++ b/js/src/jit-test/tests/for-of/array-iterator-generic.js
@@ -2,18 +2,18 @@
 // That is, it can be applied to arraylike objects and strings, not just arrays.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 function test(obj) {
     var it = Array.prototype[std_iterator].call(obj);
     for (var i = 0; i < (obj.length >>> 0); i++)
-        assertIteratorResult(it.next(), obj[i], false);
-    assertIteratorResult(it.next(), undefined, true);
+        assertIteratorNext(it, obj[i]);
+    assertIteratorDone(it, undefined);
 }
 
 test({length: 0});
 test({length: 0, 0: 'x', 1: 'y'});
 test({length: 2, 0: 'x', 1: 'y'});
 test(Object.create(['x', 'y', 'z']));
 test(Object.create({length: 2, 0: 'x', 1: 'y'}));
 test("");
--- a/js/src/jit-test/tests/for-of/array-iterator-growing-1.js
+++ b/js/src/jit-test/tests/for-of/array-iterator-growing-1.js
@@ -1,14 +1,14 @@
 // If an array with an active iterator is lengthened, the iterator visits the new elements.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var arr = [0, 1];
 var it = arr[std_iterator]();
-assertIteratorResult(it.next(), 0, false);
-assertIteratorResult(it.next(), 1, false);
+assertIteratorNext(it, 0);
+assertIteratorNext(it, 1);
 arr[2] = 2;
 arr.length = 4;
-assertIteratorResult(it.next(), 2, false);
-assertIteratorResult(it.next(), undefined, false);
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorNext(it, 2);
+assertIteratorNext(it, undefined);
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/for-of/array-iterator-proxy.js
+++ b/js/src/jit-test/tests/for-of/array-iterator-proxy.js
@@ -11,14 +11,14 @@ var it = Array.prototype[std_iterator].c
             return 2;
         } else {
             s += name;
             return name;
         }
     }
 }));
 
-assertIteratorResult(it.next(), "0", false);
+assertIteratorNext(it, "0");
 s += ' ';
-assertIteratorResult(it.next(), "1", false);
+assertIteratorNext(it, "1");
 s += ' ';
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
 assertEq(s, "L0 L1 L");
--- a/js/src/jit-test/tests/for-of/array-iterator-shrinking.js
+++ b/js/src/jit-test/tests/for-of/array-iterator-shrinking.js
@@ -1,11 +1,11 @@
 // If an array is truncated to the left of an iterator it, it.next() returns { done: true }.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var arr = [0, 1, 2];
 var it = arr[std_iterator]();
-assertIteratorResult(it.next(), 0, false);
-assertIteratorResult(it.next(), 1, false);
+assertIteratorNext(it, 0);
+assertIteratorNext(it, 1);
 arr.length = 1;
-assertIteratorResult(it.next(), undefined, true);
+assertIteratorDone(it, undefined);
--- a/js/src/jit-test/tests/for-of/manual-advance.js
+++ b/js/src/jit-test/tests/for-of/manual-advance.js
@@ -4,12 +4,12 @@ load(libdir + 'iteration.js');
 
 function* g(n) { for (var i=0; i<n; i++) yield i; }
 
 var inner = g(20);
 
 var n = 0;
 for (var x of inner) {
     assertEq(x, n * 2);
-    assertIteratorResult(inner.next(), n * 2 + 1, false);
+    assertIteratorNext(inner, n * 2 + 1);
     n++;
 }
 assertEq(n, 10);
--- a/js/src/jit-test/tests/for-of/next-3.js
+++ b/js/src/jit-test/tests/for-of/next-3.js
@@ -4,10 +4,10 @@
 
 // FIXME: 'next' should work cross-realm.  Bug 924059.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 var g = newGlobal();
 g.eval("var it = [1, 2]['" + std_iterator + "']();");
-assertIteratorResult(g.it.next(), 1, false);
+assertIteratorNext(g.it, 1);
 assertThrowsInstanceOf([][std_iterator]().next.bind(g.it), TypeError)
--- a/js/src/jit-test/tests/for-of/string-iterator-generic.js
+++ b/js/src/jit-test/tests/for-of/string-iterator-generic.js
@@ -1,15 +1,15 @@
 // String.prototype.iterator is generic.
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 function test(obj) {
     var it = String.prototype[std_iterator].call(obj);
     for (var i = 0; i < (obj.length >>> 0); i++)
-        assertIteratorResult(it.next(), obj[i], false);
-    assertIteratorResult(it.next(), undefined, true);
+        assertIteratorNext(it, obj[i]);
+    assertIteratorDone(it, undefined);
 }
 
 test({length: 0});
 test(Object.create(['x', 'y', 'z']));
 test(Object.create({length: 2, 0: 'x', 1: 'y'}));
--- a/js/src/tests/ecma_6/Generators/delegating-yield-12.js
+++ b/js/src/tests/ecma_6/Generators/delegating-yield-12.js
@@ -25,25 +25,25 @@ function IterableWrapper(iterable) {
     }
 
     return ret;
 }
 
 function* delegate(iter) { return yield* iter; }
 
 var iter = delegate(IterableWrapper([1, 2, 3]));
-assertIteratorResult(iter.next(), 1, false);
-assertIteratorResult(iter.next(), 2, false);
-assertIteratorResult(iter.next(), 3, false);
-assertIteratorResult(iter.next(), undefined, true);
+assertIteratorNext(iter, 1);
+assertIteratorNext(iter, 2);
+assertIteratorNext(iter, 3);
+assertIteratorDone(iter, undefined);
 
 assertEq(log, 'innnn');
 
 iter = delegate([1, 2, 3]);
-assertIteratorResult(iter.next(), 1, false);
-assertIteratorResult(iter.next(), 2, false);
-assertIteratorResult(iter.next(), 3, false);
-assertIteratorResult(iter.next(), undefined, true);
+assertIteratorNext(iter, 1);
+assertIteratorNext(iter, 2);
+assertIteratorNext(iter, 3);
+assertIteratorDone(iter, undefined);
 
 assertEq(log, 'innnn');
 
 if (typeof reportCompare == "function")
     reportCompare(true, true);
--- a/js/src/tests/ecma_6/Generators/delegating-yield-2.js
+++ b/js/src/tests/ecma_6/Generators/delegating-yield-2.js
@@ -4,68 +4,68 @@ function* g1() { return (yield 1); }
 function* g2() { try { yield 1; } catch (e) { yield e; } }
 function* delegate(iter) { return yield* iter; }
 var GeneratorObjectPrototype = Object.getPrototypeOf(g1).prototype;
 var GeneratorObjectPrototype_throw = GeneratorObjectPrototype.throw;
 
 // An uncaught delegated throw.
 var inner = g1();
 var outer = delegate(inner);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 assertThrowsValue(function () { outer.throw(42) }, 42);
 assertThrowsInstanceOf(function () { outer.throw(42) }, TypeError);
 
 // A caught delegated throw.
 inner = g2();
 outer = delegate(inner);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 assertIteratorResult(outer.throw(42), 42, false);
 assertThrowsValue(function () { outer.throw(42) }, 42);
 assertThrowsInstanceOf(function () { outer.throw(42) }, TypeError);
 
 // What would be an uncaught delegated throw, but with a monkeypatched iterator.
 inner = g1();
 outer = delegate(inner);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 inner.throw = function(e) { return e*2; };
 assertEq(84, outer.throw(42));
-assertIteratorResult(outer.next(), undefined, true);
+assertIteratorDone(outer, undefined);
 
 // Monkeypatching inner.next.
 inner = g1();
 outer = delegate(inner);
 inner.next = function() { return { value: 13, done: true } };
-assertIteratorResult(outer.next(), 13, true);
+assertIteratorDone(outer, 13);
 
 // What would be a caught delegated throw, but with a monkeypunched prototype.
 inner = g2();
 outer = delegate(inner);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 delete GeneratorObjectPrototype.throw;
 var outer_throw_42 = GeneratorObjectPrototype_throw.bind(outer, 42);
 assertThrowsValue(outer_throw_42, 42);
 assertThrowsInstanceOf(outer_throw_42, TypeError);
 
 // Monkeypunch a different throw handler.
 inner = g2();
 outer = delegate(inner);
 outer_throw_42 = GeneratorObjectPrototype_throw.bind(outer, 42);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 GeneratorObjectPrototype.throw = function(e) { return e*2; }
 assertEq(84, outer_throw_42());
 assertEq(84, outer_throw_42());
 // This continues indefinitely.
 assertEq(84, outer_throw_42());
-assertIteratorResult(outer.next(), undefined, true);
+assertIteratorDone(outer, undefined);
 
 // The same, but restoring the original pre-monkey throw.
 inner = g2();
 outer = delegate(inner);
 outer_throw_42 = GeneratorObjectPrototype_throw.bind(outer, 42);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 1);
 assertEq(84, outer_throw_42());
 assertEq(84, outer_throw_42());
 GeneratorObjectPrototype.throw = GeneratorObjectPrototype_throw;
 assertIteratorResult(outer_throw_42(), 42, false);
-assertIteratorResult(outer.next(), undefined, true);
+assertIteratorDone(outer, undefined);
 
 if (typeof reportCompare == "function")
     reportCompare(true, true);
--- a/js/src/tests/ecma_6/Generators/delegating-yield-3.js
+++ b/js/src/tests/ecma_6/Generators/delegating-yield-3.js
@@ -3,38 +3,38 @@
 function* g(n) { for (var i=0; i<n; i++) yield i; }
 function* delegate(iter) { return yield* iter; }
 var GeneratorObjectPrototype = Object.getPrototypeOf(g).prototype;
 var GeneratorObjectPrototype_next = GeneratorObjectPrototype.next;
 
 // Monkeypatch next on an iterator.
 var inner = g(20);
 var outer = delegate(inner);
-assertIteratorResult(outer.next(), 0, false);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 0);
+assertIteratorNext(outer, 1);
 inner.next = function() { return 0; };
 // 42 yielded directly without re-boxing.
 assertEq(0, outer.next());
 // Outer generator not terminated.
 assertEq(0, outer.next());
 // Restore.
 inner.next = GeneratorObjectPrototype_next;
-assertIteratorResult(outer.next(), 2, false);
+assertIteratorNext(outer, 2);
 // Repatch.
 inner.next = function() { return { value: 42, done: true }; };
-assertIteratorResult(outer.next(), 42, true);
+assertIteratorDone(outer, 42);
 
 // Monkeypunch next on the prototype.
 var inner = g(20);
 var outer = delegate(inner);
-assertIteratorResult(outer.next(), 0, false);
-assertIteratorResult(outer.next(), 1, false);
+assertIteratorNext(outer, 0);
+assertIteratorNext(outer, 1);
 GeneratorObjectPrototype.next = function() { return 0; };
 // 42 yielded directly without re-boxing.
 assertEq(0, GeneratorObjectPrototype_next.call(outer));
 // Outer generator not terminated.
 assertEq(0, GeneratorObjectPrototype_next.call(outer));
 // Restore.
 GeneratorObjectPrototype.next = GeneratorObjectPrototype_next;
-assertIteratorResult(outer.next(), 2, false);
+assertIteratorNext(outer, 2);
 
 if (typeof reportCompare == "function")
     reportCompare(true, true);
--- a/js/src/tests/ecma_6/Generators/delegating-yield-4.js
+++ b/js/src/tests/ecma_6/Generators/delegating-yield-4.js
@@ -2,17 +2,17 @@
 
 function* g(n) { for (var i=0; i<n; i++) yield i; }
 function* delegate(iter) { return yield* iter; }
 
 var inner = g(20);
 var outer1 = delegate(inner);
 var outer2 = delegate(inner);
 
-assertIteratorResult(outer1.next(), 0, false);
-assertIteratorResult(outer2.next(), 1, false);
-assertIteratorResult(inner.next(), 2, false);
-assertIteratorResult(outer1.next(), 3, false);
-assertIteratorResult(outer2.next(), 4, false);
-assertIteratorResult(inner.next(), 5, false);
+assertIteratorNext(outer1, 0);
+assertIteratorNext(outer2, 1);
+assertIteratorNext(inner, 2);
+assertIteratorNext(outer1, 3);
+assertIteratorNext(outer2, 4);
+assertIteratorNext(inner, 5);
 
 if (typeof reportCompare == "function")
     reportCompare(true, true);
--- a/js/src/tests/ecma_6/Generators/iteration.js
+++ b/js/src/tests/ecma_6/Generators/iteration.js
@@ -7,20 +7,18 @@
 
 
 var GeneratorFunction = (function*(){yield 1;}).constructor;
 
 
 function TestGeneratorResultPrototype() {
     function* g() { yield 1; }
     var iter = g();
-    var result = iter.next();
-    assertIteratorResult(result, 1, false);
-    result = iter.next();
-    assertIteratorResult(result, undefined, true);
+    assertIteratorNext(iter, 1);
+    assertIteratorDone(iter, undefined);
     assertThrowsInstanceOf(function() { iter.next() }, TypeError);
 }
 TestGeneratorResultPrototype();
 
 function TestGenerator(g, expected_values_for_next,
                        send_val, expected_values_for_send) {
     function testNext(thunk) {
         var iter = thunk();
@@ -329,134 +327,134 @@ TestGenerator(
     "foo",
     [42, undefined]);
 
 function TestTryCatch(instantiate) {
     function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; }
     function Sentinel() {}
 
     function Test1(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
+        assertIteratorNext(iter, 3);
+        assertIteratorDone(iter, undefined);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test1(instantiate(g));
 
     function Test2(iter) {
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test2(instantiate(g));
 
     function Test3(iter) {
-        assertIteratorResult(iter.next(), 1, false);
+        assertIteratorNext(iter, 1);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test3(instantiate(g));
 
     function Test4(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, 3);
+        assertIteratorDone(iter, undefined);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test4(instantiate(g));
 
     function Test5(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
-        assertIteratorResult(iter.next(), 3, false);
+        assertIteratorNext(iter, 3);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
 
     }
     Test5(instantiate(g));
 
     function Test6(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test6(instantiate(g));
 }
 TestTryCatch(function (g) { return g(); });
 TestTryCatch(function* (g) { return yield* g(); });
 
 function TestTryFinally(instantiate) {
     function* g() { yield 1; try { yield 2; } finally { yield 3; } yield 4; }
     function Sentinel() {}
     function Sentinel2() {}
 
     function Test1(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), 4, false);
-        assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
+        assertIteratorNext(iter, 3);
+        assertIteratorNext(iter, 4);
+        assertIteratorDone(iter, undefined);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test1(instantiate(g));
 
     function Test2(iter) {
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test2(instantiate(g));
 
     function Test3(iter) {
-        assertIteratorResult(iter.next(), 1, false);
+        assertIteratorNext(iter, 1);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test3(instantiate(g));
 
     function Test4(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         assertIteratorResult(iter.throw(new Sentinel), 3, false);
         assertThrowsInstanceOf(function() { iter.next(); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
 
     }
     Test4(instantiate(g));
 
     function Test5(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         assertIteratorResult(iter.throw(new Sentinel), 3, false);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel2); }, Sentinel2);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test5(instantiate(g));
 
     function Test6(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
-        assertIteratorResult(iter.next(), 3, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
+        assertIteratorNext(iter, 3);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test6(instantiate(g));
 
     function Test7(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), 4, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
+        assertIteratorNext(iter, 3);
+        assertIteratorNext(iter, 4);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test7(instantiate(g));
 }
 TestTryFinally(function (g) { return g(); });
 TestTryFinally(function* (g) { return yield* g(); });
 
@@ -470,79 +468,79 @@ function TestNestedTry(instantiate) {
             yield 4;
         }
         yield 5;
     }
     function Sentinel() {}
     function Sentinel2() {}
 
     function Test1(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), 4, false);
-        assertIteratorResult(iter.next(), 5, false);
-        assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
+        assertIteratorNext(iter, 3);
+        assertIteratorNext(iter, 4);
+        assertIteratorNext(iter, 5);
+        assertIteratorDone(iter, undefined);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test1(instantiate(g));
 
     function Test2(iter) {
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test2(instantiate(g));
 
     function Test3(iter) {
-        assertIteratorResult(iter.next(), 1, false);
+        assertIteratorNext(iter, 1);
         assertIteratorResult(iter.throw(new Sentinel), 4, false);
         assertThrowsInstanceOf(function() { iter.next(); }, Sentinel);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test3(instantiate(g));
 
     function Test4(iter) {
-        assertIteratorResult(iter.next(), 1, false);
+        assertIteratorNext(iter, 1);
         assertIteratorResult(iter.throw(new Sentinel), 4, false);
         assertThrowsInstanceOf(function() { iter.throw(new Sentinel2); }, Sentinel2);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test4(instantiate(g));
 
     function Test5(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
-        assertIteratorResult(iter.next(), 3, false);
-        assertIteratorResult(iter.next(), 4, false);
-        assertIteratorResult(iter.next(), 5, false);
-        assertIteratorResult(iter.next(), undefined, true);
+        assertIteratorNext(iter, 3);
+        assertIteratorNext(iter, 4);
+        assertIteratorNext(iter, 5);
+        assertIteratorDone(iter, undefined);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
 
     }
     Test5(instantiate(g));
 
     function Test6(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
         assertIteratorResult(iter.throw(new Sentinel2), 4, false);
         assertThrowsInstanceOf(function() { iter.next(); }, Sentinel2);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
     }
     Test6(instantiate(g));
 
     function Test7(iter) {
-        assertIteratorResult(iter.next(), 1, false);
-        assertIteratorResult(iter.next(), 2, false);
+        assertIteratorNext(iter, 1);
+        assertIteratorNext(iter, 2);
         var exn = new Sentinel;
         assertIteratorResult(iter.throw(exn), exn, false);
-        assertIteratorResult(iter.next(), 3, false);
+        assertIteratorNext(iter, 3);
         assertIteratorResult(iter.throw(new Sentinel2), 4, false);
         assertThrowsInstanceOf(function() { iter.next(); }, Sentinel2);
         assertThrowsInstanceOf(function() { iter.next(); }, TypeError);
 
     }
     Test7(instantiate(g));
 
     // That's probably enough.
--- a/js/src/tests/ecma_6/Generators/shell.js
+++ b/js/src/tests/ecma_6/Generators/shell.js
@@ -15,8 +15,14 @@ var std_iterator = (function() {
 
 function assertFalse(a) { assertEq(a, false) }
 function assertTrue(a) { assertEq(a, true) }
 function assertNotEq(found, not_expected) { assertFalse(found === expected) }
 function assertIteratorResult(result, value, done) {
     assertDeepEq(result.value, value);
     assertEq(result.done, done);
 }
+function assertIteratorNext(iter, value) {
+    assertIteratorResult(iter.next(), value, false);
+}
+function assertIteratorDone(iter, value) {
+    assertIteratorResult(iter.next(), value, true);
+}