cptn-no-else-true-abrupt-empty.js (986B)
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 esid: sec-if-statement-runtime-semantics-evaluation 5 description: > 6 Completion value when expression is true without an `else` clause and body 7 returns an empty abrupt completion 8 info: | 9 IfStatement : if ( Expression ) Statement 10 11 3. If exprValue is false, then 12 [...] 13 4. Else, 14 a. Let stmtCompletion be the result of evaluating Statement. 15 b. Return Completion(UpdateEmpty(stmtCompletion, undefined)). 16 ---*/ 17 18 assert.sameValue( 19 eval('1; do { 2; if (true) { 3; break; } 4; } while (false)'), 3 20 ); 21 assert.sameValue( 22 eval('5; do { 6; if (true) { break; } 7; } while (false)'), undefined 23 ); 24 25 assert.sameValue( 26 eval('8; do { 9; if (true) { 10; continue; } 11; } while (false)'), 10 27 ); 28 assert.sameValue( 29 eval('12; do { 13; if (true) { continue; } 14; } while (false)'), undefined 30 ); 31 32 reportCompare(0, 0);