js/src/jit-test/tests/for-of/value-done-access.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/for-of/value-done-access.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +// Test that each yield* loop just checks "done", and "value" is only
     1.5 +// fetched once at the end.
     1.6 +
     1.7 +load(libdir + 'iteration.js');
     1.8 +
     1.9 +var log = "";
    1.10 +
    1.11 +function Iter(val, count) {
    1.12 +    function next() {
    1.13 +        return {
    1.14 +            get done() { log += "d"; return count-- == 0; },
    1.15 +            get value() { log += "v"; return val; }
    1.16 +        }
    1.17 +    }
    1.18 +
    1.19 +    this[std_iterator] = function() { return this; };
    1.20 +    this.next = next;
    1.21 +}
    1.22 +
    1.23 +for (var x of new Iter(42, 5))
    1.24 +    assertEq(x, 42);
    1.25 +
    1.26 +assertEq(log, "dvdvdvdvdvd");

mercurial