Debian Codegraph @

js/src/tests/test262/language/statements/for/cptn-decl-expr-iter.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.4.7
5 description: >
6 Completion value when head has a declaration and a "test" expression and iteration occurs
7 info: |
8 IterationStatement :
9 for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
10
11 1. Let varDcl be the result of evaluating VariableDeclarationList.
12 2. ReturnIfAbrupt(varDcl).
13 3. Return ForBodyEvaluation(the first Expression, the second Expression,
14 Statement, « », labelSet).
15
16 13.7.4.8 Runtime Semantics: ForBodyEvaluation
17 1. Let V = undefined.
18 [...]
19 4. Repeat
20 a. If test is not [empty], then
21 i. Let testRef be the result of evaluating test.
22 ii. Let testValue be GetValue(testRef).
23 iii. ReturnIfAbrupt(testValue).
24 iv. If ToBoolean(testValue) is false, return NormalCompletion(V).
25 ---*/
26
27 assert.sameValue(
28 eval('1; for (var runA = true; runA; runA = false) { }'), undefined
29 );
30 assert.sameValue(
31 eval('2; for (var runB = true; runB; runB = false) { 3; }'), 3
32 );
33
34 reportCompare(0, 0);