Debian Codegraph @

js/src/tests/test262/language/statements/for-of/cptn-decl-abrupt-empty.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 13.7.5.11
5 description: >
6 Completion value when head has a declaration and iteration is cancelled
7 info: |
8 IterationStatement : for ( var ForBinding of AssignmentExpression ) Statement
9
10 1. Let keyResult be the result of performing ForIn/OfHeadEvaluation( « »,
11 AssignmentExpression, iterate).
12 2. ReturnIfAbrupt(keyResult).
13 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult,
14 varBinding, labelSet).
15
16 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
17
18 [...]
19 2. Let V = undefined.
20 [...]
21 5. Repeat
22 a. Let nextResult be IteratorStep(iterator).
23 b. ReturnIfAbrupt(nextResult).
24 c. If nextResult is false, return NormalCompletion(V).
25 [...]
26 k. Let result be the result of evaluating stmt.
27 [...]
28 m. If LoopContinues(result, labelSet) is false, return
29 IteratorClose(iterator, UpdateEmpty(result, V)).
30 ---*/
31
32 assert.sameValue(eval('1; for (var a of [0]) { break; }'), undefined);
33 assert.sameValue(eval('2; for (var b of [0]) { 3; break; }'), 3);
34
35 assert.sameValue(
36 eval('4; outer: do { for (var a of [0]) { continue outer; } } while (false)'),
37 undefined
38 );
39 assert.sameValue(
40 eval('5; outer: do { for (var b of [0]) { 6; continue outer; } } while (false)'),
41 6
42 );
43
44 reportCompare(0, 0);