Debian Codegraph @

js/src/jit-test/tests/for-of/semantics-07.js

raw
1 // Deleting the .next method of an iterator in the middle of a for-of loop
2 // doesn't cause a TypeError at the next iteration.
3
4 load(libdir + "asserts.js");
5 load(libdir + "iteration.js");
6
7 var iterProto = Object.getPrototypeOf([][Symbol.iterator]());
8 var s = '';
9 for (var v of ['duck', 'duck', 'duck', 'goose', 'and now you\'re it']) {
10 s += v;
11 if (v === 'goose')
12 delete iterProto.next;
13 s += '.';
14 }
15 assertEq(s, 'duck.duck.duck.goose.and now you\'re it.');