| 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 // Flags: --harmony-sloppy --harmony-sloppy-let --legacy-const | 5 // Flags: --harmony-sloppy --harmony-sloppy-let |
| 6 | 6 |
| 7 // let is usable as a variable with var or legacy const, not let or ES6 const | 7 // let is usable as a variable with var, but not let or ES6 const |
| 8 | 8 |
| 9 (function (){ | 9 (function (){ |
| 10 assertEquals(undefined, let); | 10 assertEquals(undefined, let); |
| 11 | 11 |
| 12 var let; | 12 var let; |
| 13 | 13 |
| 14 let = 5; | 14 let = 5; |
| 15 assertEquals(5, let); | 15 assertEquals(5, let); |
| 16 | 16 |
| 17 (function() { var let = 1; assertEquals(1, let); })(); | 17 (function() { var let = 1; assertEquals(1, let); })(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 | 42 |
| 43 assertThrows(function() { return let; }, ReferenceError); | 43 assertThrows(function() { return let; }, ReferenceError); |
| 44 | 44 |
| 45 (function () { | 45 (function () { |
| 46 let obj = {}; | 46 let obj = {}; |
| 47 var {let} = {let() { return obj; }}; | 47 var {let} = {let() { return obj; }}; |
| 48 let().x = 1; | 48 let().x = 1; |
| 49 assertEquals(1, obj.x); | 49 assertEquals(1, obj.x); |
| 50 })(); | 50 })(); |
| 51 | 51 |
| 52 (function () { | |
| 53 let obj = {}; | |
| 54 const [let] = [function() { return obj; }]; | |
| 55 let().x = 1; | |
| 56 assertEquals(1, obj.x); | |
| 57 })(); | |
| 58 | |
| 59 (function() { | 52 (function() { |
| 60 function let() { | 53 function let() { |
| 61 return 1; | 54 return 1; |
| 62 } | 55 } |
| 63 assertEquals(1, let()); | 56 assertEquals(1, let()); |
| 64 })() | 57 })() |
| 65 | 58 |
| 66 assertThrows('for (let of []) {}', SyntaxError); | 59 assertThrows('for (let of []) {}', SyntaxError); |
| OLD | NEW |