| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --harmony-modules | 28 // Flags: --harmony-modules |
| 29 | 29 |
| 30 // Test basic module syntax, with and without ASI. | 30 // Test basic module syntax, with and without automatic semicolon insertion. |
| 31 | 31 |
| 32 module A {} | 32 module A {} |
| 33 | 33 |
| 34 module A1 = A | 34 module A1 = A |
| 35 module A2 = A; | 35 module A2 = A; |
| 36 module A3 = A2 | 36 module A3 = A2 |
| 37 | 37 |
| 38 module B { | 38 module B { |
| 39 export x | 39 export vx |
| 40 export y, z, c, f | 40 export vy, lz, c, f |
| 41 | 41 |
| 42 var vx | 42 var vx |
| 43 var vx, vy; | 43 var vx, vy; |
| 44 var vx = 0, vy | 44 var vx = 0, vy |
| 45 let lx, ly | 45 let lx, ly |
| 46 let lz = 1 | 46 let lz = 1 |
| 47 const c = 9 | 47 const c = 9 |
| 48 function f() {} | 48 function f() {} |
| 49 | 49 |
| 50 module C { | 50 module C0 {} |
| 51 |
| 52 export module C { |
| 51 let x | 53 let x |
| 52 module D {} | 54 export module D { export let x } |
| 53 let y | 55 let y |
| 54 } | 56 } |
| 55 | 57 |
| 56 let zz = "" | 58 let zz = "" |
| 57 | 59 |
| 58 export var x0 | 60 export var x0 |
| 59 export var x1, x2 = 6, x3 | 61 export var x1, x2 = 6, x3 |
| 60 export let y0 | 62 export let y0 |
| 61 export let y1 = 0, y2 | 63 export let y1 = 0, y2 |
| 62 export const z0 = 0 | 64 export const z0 = 0 |
| 63 export const z1 = 2, z2 = 3 | 65 export const z1 = 2, z2 = 3 |
| 64 export function f0() {} | 66 export function f0() {} |
| 65 export module M1 {} | 67 export module M1 {} |
| 66 export module M2 = C.D | 68 export module M2 = C.D |
| 67 export module M3 at "http://where" | 69 export module M3 at "http://where" |
| 68 | 70 |
| 69 import i0 from I | 71 import i0 from I |
| 70 import i1, i2, i3 from I | 72 import i1, i2, i3, M from I |
| 71 import i4, i5 from "http://where" | 73 import i4, i5 from "http://where" |
| 72 } | 74 } |
| 73 | 75 |
| 76 module I { |
| 77 export let i0, i1, i2, i3; |
| 78 export module M {} |
| 79 } |
| 80 |
| 74 module C1 = B.C; | 81 module C1 = B.C; |
| 75 module D1 = B.C.D | 82 module D1 = B.C.D |
| 76 module D2 = C1.D | 83 module D2 = C1.D |
| 77 module D3 = D2 | 84 module D3 = D2 |
| 78 | 85 |
| 79 module E1 at "http://where" | 86 module E1 at "http://where" |
| 80 module E2 at "http://where"; | 87 module E2 at "http://where"; |
| 81 module E3 = E1.F | 88 module E3 = E1.F |
| 82 | 89 |
| 83 | |
| 84 // Check that ASI does not interfere. | 90 // Check that ASI does not interfere. |
| 85 | 91 |
| 86 module X | 92 module X |
| 87 { | 93 { |
| 88 let x | 94 let x |
| 89 } | 95 } |
| 90 | 96 |
| 91 module Y | 97 module Y |
| 92 = | 98 = |
| 93 X | 99 X |
| 94 | 100 |
| 95 module Z | 101 module Z |
| 96 at | 102 at |
| 97 "file://local" | 103 "file://local" |
| 98 | 104 |
| 99 import | 105 import |
| 100 x | 106 x |
| 101 , | 107 , |
| 102 y | 108 y |
| 103 from | 109 from |
| 104 "file://local" | 110 "file://local" |
| 105 | 111 |
| 112 |
| 106 module Wrap { | 113 module Wrap { |
| 107 export | 114 export |
| 108 x | 115 x |
| 109 , | 116 , |
| 110 y | 117 y |
| 111 | 118 |
| 112 export | 119 export |
| 113 var | 120 var |
| 114 v1 = 1 | 121 v1 = 1 |
| 115 | 122 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 ) | 135 ) |
| 129 { | 136 { |
| 130 } | 137 } |
| 131 | 138 |
| 132 export | 139 export |
| 133 module V | 140 module V |
| 134 { | 141 { |
| 135 } | 142 } |
| 136 } | 143 } |
| 137 | 144 |
| 145 export A, A1, A2, A3, B, I, C1, D1, D2, D3, E1, E2, E3, X, Y, Z, Wrap, x, y, UU |
| 146 |
| 147 |
| 138 | 148 |
| 139 // Check that 'module' still works as an identifier. | 149 // Check that 'module' still works as an identifier. |
| 140 | 150 |
| 141 var module | 151 var module |
| 142 module = {} | 152 module = {} |
| 143 module["a"] = 6 | 153 module["a"] = 6 |
| 144 function module() {} | 154 function module() {} |
| 145 function f(module) { return module } | 155 function f(module) { return module } |
| 146 try {} catch (module) {} | 156 try {} catch (module) {} |
| 147 | 157 |
| 148 module | 158 module |
| 149 v = 20 | 159 v = 20 |
| OLD | NEW |