Debian Codegraph @

js/src/tests/test262/language/statements/if/cptn-else-true-nrml.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.6.7
5 description: >
6 Completion value when expression is true with an `else` clause and body
7 returns a normal completion
8 info: |
9 IfStatement : if ( Expression ) Statement else Statement
10
11 4. If exprValue is true, then
12 a. Let stmtCompletion be the result of evaluating the first Statement.
13 5. Else,
14 [...]
15 6. ReturnIfAbrupt(stmtCompletion).
16 7. If stmtCompletion.[[value]] is not empty, return stmtCompletion.
17 8. Return NormalCompletion(undefined).
18 ---*/
19
20 assert.sameValue(eval('1; if (true) { } else { }'), undefined);
21 assert.sameValue(eval('2; if (true) { 3; } else { }'), 3);
22 assert.sameValue(eval('4; if (true) { } else { 5; }'), undefined);
23 assert.sameValue(eval('6; if (true) { 7; } else { 8; }'), 7);
24
25 reportCompare(0, 0);