Debian Codegraph @

js/src/tests/test262/language/statements/while/cptn-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.3.6
5 description: >
6 Completion value when iteration completes due to an empty abrupt completion
7 info: |
8 IterationStatement : while ( Expression ) Statement
9
10 1. Let V = undefined.
11 2. Repeat
12 a. Let exprRef be the result of evaluating Expression.
13 b. Let exprValue be GetValue(exprRef).
14 c. ReturnIfAbrupt(exprValue).
15 d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
16 e. Let stmt be the result of evaluating Statement.
17 f. If LoopContinues (stmt, labelSet) is false, return
18 Completion(UpdateEmpty(stmt, V)).
19 ---*/
20
21 assert.sameValue(eval('1; while (true) { break; }'), undefined);
22 assert.sameValue(eval('2; while (true) { 3; break; }'), 3);
23
24 assert.sameValue(
25 eval('4; outer: do { while (true) { continue outer; } } while (false)'),
26 undefined
27 );
28 assert.sameValue(
29 eval('5; outer: do { while (true) { 6; continue outer; } } while (false)'), 6
30 );
31
32 reportCompare(0, 0);