Debian Codegraph @

js/src/tests/non262/statements/for-of-iterator-close.js

raw
1 // SKIP test262 export
2 // https://github.com/tc39/ecma262/pull/2193
3 // Tests that IteratorReturn is called when a for-of loop has an abrupt
4 // completion value during non-iterator code.
5
6 function test() {
7 var returnCalled = 0;
8 var returnCalledExpected = 0;
9 var iterable = {};
10 iterable[Symbol.iterator] = makeIterator({
11 ret: function() {
12 returnCalled++;
13 return {};
14 }
15 });
16
17 // throw in lhs ref calls iter.return
18 function throwlhs() {
19 throw "in lhs";
20 }
21 assertThrowsValue(function() {
22 for ((throwlhs()) of iterable)
23 continue;
24 }, "in lhs");
25 assertEq(returnCalled, ++returnCalledExpected);
26 }
27
28 test();
29
30 if (typeof reportCompare === "function")
31 reportCompare(0, 0);