| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 function assertUndef(x) { | 6 function assertUndef(x) { |
| 7 assertEquals(undefined, x); | 7 assertEquals(undefined, x); |
| 8 } | 8 } |
| 9 | 9 |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 assertEquals(0, eval( | 100 assertEquals(0, eval( |
| 101 '42; while (1) { try { 666 } finally {0; break} }')); | 101 '42; while (1) { try { 666 } finally {0; break} }')); |
| 102 assertEquals(0, eval( | 102 assertEquals(0, eval( |
| 103 '42; while (1) { try { 666; break } finally {0; break} }')); | 103 '42; while (1) { try { 666; break } finally {0; break} }')); |
| 104 assertEquals(0, eval( | 104 assertEquals(0, eval( |
| 105 '42; lab: try { 666; break lab } finally {0; break lab}')); | 105 '42; lab: try { 666; break lab } finally {0; break lab}')); |
| 106 assertEquals(undefined, eval( | 106 assertEquals(undefined, eval( |
| 107 'var b = 1; ' + | 107 'var b = 1; ' + |
| 108 'outer: while (1) { while (1) { if (b--) 42; else break outer; }; 666 }')); | 108 'outer: while (1) { while (1) { if (b--) 42; else break outer; }; 666 }')); |
| 109 | 109 |
| 110 // The following is not what ES6 says, but see ES bug 4540. | |
| 111 assertUndef(eval('42; switch (0) { case 0: 1; if (true) break; }')); // ES5: 1 | 110 assertUndef(eval('42; switch (0) { case 0: 1; if (true) break; }')); // ES5: 1 |
| 112 | 111 |
| 112 assertUndef(eval('a: while(true) { do { 0 } while(false); switch(1) { case 0: 1;
case 1: break a; }; 0 }')); |
| 113 assertUndef(eval('a: while(true) { do { 0 } while(false); try {} finally { break
a }; 0 }')); |
| 114 assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; switch(1) { c
ase 1: break a; }; 2 }')); |
| 115 assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; while (true)
{ break a; }; 2 }')); |
| 116 assertUndef(eval('while (true) { 20; a:{ break a; } with ({}) break; 30; }')); |
| 117 assertEquals(42, eval('a: while(true) { switch(0) { case 0: 42; case 1: break a;
}; 33 }')); |
| 118 |
| 119 assertUndef(eval( |
| 120 'for (var i = 0; i < 2; ++i) { if (i) { try {} finally { break; } } 0; }' |
| 121 )); |
| 122 assertUndef(eval( |
| 123 'for (var i = 0; i < 2; ++i) { if (i) { try {} finally { continue; } } 0; }' |
| 124 )); |
| 125 |
| 113 | 126 |
| 114 | 127 |
| 115 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 116 // | 129 // |
| 117 // The following are copied from webkit/eval-throw-return and adapted. | 130 // The following are copied from webkit/eval-throw-return and adapted. |
| 118 | 131 |
| 119 function throwFunc() { | 132 function throwFunc() { |
| 120 throw ""; | 133 throw ""; |
| 121 } | 134 } |
| 122 | 135 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 139 assertUndef(eval("var x = 1;")); | 152 assertUndef(eval("var x = 1;")); |
| 140 assertEquals(1, eval("if (true) { 1; } else { 2; }")); | 153 assertEquals(1, eval("if (true) { 1; } else { 2; }")); |
| 141 assertEquals(2, eval("if (false) { 1; } else { 2; }")); | 154 assertEquals(2, eval("if (false) { 1; } else { 2; }")); |
| 142 assertUndef(eval("try{1; if (true) { 2; throw ''; } else { 2; }} catch(e){}")); | 155 assertUndef(eval("try{1; if (true) { 2; throw ''; } else { 2; }} catch(e){}")); |
| 143 assertEquals(2, eval("1; var i = 0; do { ++i; 2; } while(i!=1);")); | 156 assertEquals(2, eval("1; var i = 0; do { ++i; 2; } while(i!=1);")); |
| 144 assertUndef(eval( | 157 assertUndef(eval( |
| 145 "try{1; var i = 0; do { ++i; 2; throw ''; } while (i!=1);} catch(e){}")); | 158 "try{1; var i = 0; do { ++i; 2; throw ''; } while (i!=1);} catch(e){}")); |
| 146 assertUndef(eval("1; try{2; throwOnReturn();} catch(e){}")); | 159 assertUndef(eval("1; try{2; throwOnReturn();} catch(e){}")); |
| 147 assertUndef(eval("1; twoFunc();")); | 160 assertUndef(eval("1; twoFunc();")); |
| 148 assertEquals(2, eval("1; with ( { a: 0 } ) { 2; }")); | 161 assertEquals(2, eval("1; with ( { a: 0 } ) { 2; }")); |
| 149 | |
| 150 assertUndef(eval('a: while(true) { do { 0 } while(false); switch(1) { case 0: 1;
case 1: break a; }; 0 }')); | |
| 151 assertUndef(eval('a: while(true) { do { 0 } while(false); try {} finally { break
a }; 0 }')); | |
| 152 assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; switch(1) { c
ase 1: break a; }; 2 }')); | |
| 153 assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; while (true)
{ break a; }; 2 }')); | |
| 154 assertUndef(eval('while (true) { 20; a:{ break a; } with ({}) break; 30; }')); | |
| 155 assertEquals(42, eval('a: while(true) { switch(0) { case 0: 42; case 1: break a;
}; 33 }')); | |
| OLD | NEW |