1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28 // Flags: --harmony-modules --harmony-scoping
30 // Test basic module interface inference.
37 export let x = print("0")
42 export let x = print("1")
43 export let f = function() { return B.x }
50 try { A.y } catch (e) {} // throws
51 let Az = A.z // undefined
52 let Az2 = z // undefined
62 function f(x,y) { return x }
64 export let y = print("4")
65 export var z = print("4.1")
66 export function g() {}
71 export let z = print("5")
73 // TODO(rossberg): turn these into proper negative test cases once we have
74 // suitable error messages.
75 // import C.z // multiple declarations
79 // TODO(rossberg): Handle import *.
80 // import A.* // invalid forward import
83 // TODO(rossberg): Handle import *.
84 // import M.* // invalid forward import
89 export module Imports {
94 // TODO(rossberg): Handle import *.
96 // import A2.* // unbound variable A2
104 // TODO(rossberg): Handle import *.
111 export module A2 = M2
114 export module A1 = M1
117 // TODO(rossberg): turn these into proper negative test cases once we have
118 // suitable error messages.
120 // module W2 = { export module W = W3 }
121 // module W3 = W1 // cyclic module definition
125 // export module W3 = W4
126 // export module W4 = W1
127 // } // cyclic module definition
129 // TODO(rossberg): Handle import *.
132 // export module B { export let x = "" }
133 // module C1 = { import M3.* }
134 // module C2 = { import M3.B.* }
135 // module C3 = { import M3B.* }
136 // module C4 = { export x import B.* }
137 //// TODO(rossberg): turn these into proper negative test cases once we have
138 //// suitable error messages.
139 //// export module C5 = { import C5.* } // invalid forward import
140 //// export module C6 = { import M3.C6.* } // invalid forward import
143 export module External at "external.js"
144 export module External1 = External
145 //export module ExternalA = External.A
146 export module InnerExternal {
147 export module E at "external.js"
149 export module External2 = InnerExternal.E
150 //export let xxx = InnerExternal.E.A.x