OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-completion |
| 6 |
| 7 |
| 8 function assertUndef(x) { |
| 9 assertEquals(undefined, x); |
| 10 } |
| 11 |
| 12 |
| 13 // IfStatement [13.6.7] |
| 14 assertUndef(eval('42; if (true) ; else 0;')); // ES5: 42 |
| 15 assertUndef(eval('42; if (true) ;')); // ES5: 42 |
| 16 assertUndef(eval('42; if (false) 0;')); // ES5: 42 |
| 17 |
| 18 |
| 19 // IterationStatement [13.7] (a few of them) |
| 20 assertUndef(eval('42; do ; while (false);')); // ES5: 42 |
| 21 assertUndef(eval('42; var x = 1; do ; while (x--);')); // ES5: 42 |
| 22 assertUndef(eval('42; while (false) 0;')); // ES5: 42 |
| 23 assertUndef(eval('42; while (true) break;')); // ES5: 42 |
| 24 assertUndef(eval('42; var x = 1; while (x--) ;')); // ES5: 42 |
| 25 assertUndef(eval('42; for (; false; ) 0;')); // ES5: 42 |
| 26 assertUndef(eval('42; for (var x = 1; x; x--) ;')); // ES5: 42 |
| 27 |
| 28 |
| 29 // WithStatement [13.11.7] |
| 30 assertUndef(eval('42; with ({}) ;')); // ES5: 42 |
| 31 |
| 32 |
| 33 // SwitchStatement [13.12.11] |
| 34 assertUndef(eval('42; switch (0) {};')); // ES5: 42 |
| 35 assertUndef(eval('42; switch (0) { case 1: 1; };')); // ES5: 42 |
| 36 assertUndef(eval('42; switch (0) { case 0: ; };')); // ES5: 42 |
| 37 assertUndef(eval('42; switch (0) { default: ; };')); // ES5: 42 |
| 38 assertUndef(eval('42; switch (0) { case 0: break; }')); // ES5: 42 |
| 39 assertEquals(0, eval('42; switch (0) { case 0: 0; }')); |
| 40 assertEquals(0, eval('42; switch (0) { case 0: 0; break; }')); |
| 41 |
| 42 |
| 43 // TryStatement [13.15.8] |
| 44 assertUndef(eval('42; try { } catch(e) { };')); // ES5: 42 |
| 45 assertUndef(eval('42; try { } catch(e) { 0; };')); // ES5: 42 |
| 46 assertUndef(eval('42; try { throw Error } catch(e) { };')); // ES5: 42 |
| 47 assertUndef(eval('42; try { throw Error } catch(e) { } finally { };')); // ES5:
42 |
| 48 |
| 49 |
| 50 // Some combinations |
| 51 assertUndef(eval('42; switch (0) { case 0: if (true) break; }')); // ES5: 42 |
| 52 assertUndef(eval('42; switch (0) { case 0: 0; if (true) ; }')); // ES5: 0 |
| 53 assertUndef(eval('42; switch (0) { case 0: 0; try { break } catch(e) { }; }'));
// ES5: 0 |
| 54 |
| 55 // The following is not what ES6 says, but see ES bug 4540. |
| 56 assertUndef(eval('42; switch (0) { case 0: 0; if (true) break; }')); // ES5: 0 |
OLD | NEW |