diff -r 000000000000 -r 6474c204b198 js/src/jit-test/tests/for-of/value-done-access.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/jit-test/tests/for-of/value-done-access.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,23 @@ +// Test that each yield* loop just checks "done", and "value" is only +// fetched once at the end. + +load(libdir + 'iteration.js'); + +var log = ""; + +function Iter(val, count) { + function next() { + return { + get done() { log += "d"; return count-- == 0; }, + get value() { log += "v"; return val; } + } + } + + this[std_iterator] = function() { return this; }; + this.next = next; +} + +for (var x of new Iter(42, 5)) + assertEq(x, 42); + +assertEq(log, "dvdvdvdvdvd");