cptn-iter.js (982B)
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 expression value 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 g. If stmt.[[value]] is not empty, let V = stmt.[[value]]. 20 ---*/ 21 22 assert.sameValue(eval('var count1 = 2; 1; while (count1 -= 1) { }'), undefined); 23 assert.sameValue(eval('var count2 = 2; 2; while (count2 -= 1) { 3; }'), 3); 24 25 reportCompare(0, 0);