OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 // MODULE |
| 6 |
| 7 export var myvar = "VAR"; |
| 8 assertEquals("VAR", myvar); |
| 9 assertEquals("VAR", eval("myvar")); |
| 10 (() => assertEquals("VAR", myvar))(); |
| 11 |
| 12 export let mylet = "LET"; |
| 13 assertEquals("LET", mylet); |
| 14 assertEquals("LET", eval("mylet")); |
| 15 (() => assertEquals("LET", mylet))(); |
| 16 |
| 17 export const myconst = "CONST"; |
| 18 assertEquals("CONST", myconst); |
| 19 assertEquals("CONST", eval("myconst")); |
| 20 (() => assertEquals("CONST", myconst))(); |
| 21 |
| 22 |
| 23 myvar = 1; |
| 24 assertEquals(1, myvar); |
| 25 assertEquals(1, eval("myvar")); |
| 26 (() => assertEquals(1, myvar))(); |
| 27 (() => myvar = 2)(); |
| 28 assertEquals(2, myvar); |
| 29 (() => assertEquals(2, myvar))(); |
| 30 { |
| 31 let f = () => assertEquals(2, myvar); |
| 32 f(); |
| 33 } |
| 34 |
| 35 mylet = 1; |
| 36 assertEquals(1, mylet); |
| 37 assertEquals(1, eval("mylet")); |
| 38 (() => assertEquals(1, mylet))(); |
| 39 (() => mylet = 2)(); |
| 40 assertEquals(2, mylet); |
| 41 assertEquals(2, eval("mylet")); |
| 42 (() => assertEquals(2, mylet))(); |
| 43 { |
| 44 let f = () => assertEquals(2, mylet); |
| 45 f(); |
| 46 } |
| 47 |
| 48 assertThrows(() => myconst = 1, TypeError); |
| 49 assertEquals("CONST", myconst); |
| 50 assertEquals("CONST", eval("myconst")); |
| 51 (() => assertEquals("CONST", myconst))(); |
| 52 { |
| 53 let f = () => assertEquals("CONST", myconst); |
| 54 f(); |
| 55 } |
OLD | NEW |