| 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 // Var-let conflict in a function throws, even if the var is in an eval | 5 // Var-let conflict in a function throws, even if the var is in an eval |
| 6 | 6 |
| 7 // Throws at the top level of a function | 7 // Throws at the top level of a function |
| 8 assertThrows(function() { | 8 assertThrows(function() { |
| 9 let x = 1; | 9 let x = 1; |
| 10 eval('var x'); | 10 eval('var x'); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 { | 117 { |
| 118 let x = 1; | 118 let x = 1; |
| 119 eval('function x() {}'); | 119 eval('function x() {}'); |
| 120 } | 120 } |
| 121 })(); | 121 })(); |
| 122 } catch (e) { | 122 } catch (e) { |
| 123 caught = true; | 123 caught = true; |
| 124 } | 124 } |
| 125 assertTrue(caught); | 125 assertTrue(caught); |
| 126 | 126 |
| 127 // TODO(littledan): Hoisting x out of the block should be | |
| 128 // prevented in this case BUG(v8:4479) | |
| 129 caught = false | 127 caught = false |
| 130 try { | 128 try { |
| 131 (function() { | 129 (function() { |
| 132 { | 130 { |
| 133 let x = 1; | 131 let x = 1; |
| 134 eval('{ function x() {} }'); | 132 eval('{ function x() {} }'); |
| 135 } | 133 } |
| 136 })(); | 134 })(); |
| 137 } catch (e) { | 135 } catch (e) { |
| 138 caught = true; | 136 caught = true; |
| 139 } | 137 } |
| 140 // TODO(littledan): switch to assertTrue when bug is fixed | 138 assertFalse(caught); |
| 141 assertTrue(caught); | |
| OLD | NEW |