js/src/tests/ecma_6/Generators/delegating-yield-11.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_6/Generators/delegating-yield-11.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,20 @@
     1.4 +// The first call to yield* passes one arg to "next".
     1.5 +
     1.6 +function Iter() {
     1.7 +    function next() {
     1.8 +        if (arguments.length != 1)
     1.9 +            throw Error;
    1.10 +        return { value: 42, done: true }
    1.11 +    }
    1.12 +
    1.13 +    this.next = next;
    1.14 +    this[std_iterator] = function () { return this; }
    1.15 +}
    1.16 +
    1.17 +function* delegate(iter) { return yield* iter; }
    1.18 +
    1.19 +var iter = delegate(new Iter());
    1.20 +assertDeepEq(iter.next(), {value:42, done:true});
    1.21 +
    1.22 +if (typeof reportCompare == "function")
    1.23 +    reportCompare(true, true);

mercurial