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