Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: test/mjsunit/harmony/module-parsing.js

Issue 881623002: Begin modernization of --harmony-modules (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Dealt with rossberg comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 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 automatic semicolon insertion. 30 // Check that import/export declarations are rejected in eval or local scope.
31 31 assertThrows("export x;", SyntaxError);
32 module A {}
33
34 module A1 = A
35 module A2 = A;
36 module A3 = A2
37
38 module B {
39 export vx
40 export vy, lz, c, f
41
42 var vx
43 var vx, vy;
44 var vx = 0, vy
45 let lx, ly
46 let lz = 1
47 const c = 9
48 function f() {}
49
50 module C0 {}
51
52 export module C {
53 let x
54 export module D { export let x }
55 let y
56 }
57
58 let zz = ""
59
60 export var x0
61 export var x1, x2 = 6, x3
62 export let y0
63 export let y1 = 0, y2
64 export const z0 = 0
65 export const z1 = 2, z2 = 3
66 export function f0() {}
67 export module M1 {}
68 export module M2 = C.D
69 export module M3 at "http://where"
70
71 import i0 from I
72 import i1, i2, i3, M from I
73 //import i4, i5 from "http://where"
74 }
75
76 module I {
77 export let i0, i1, i2, i3;
78 export module M {}
79 }
80
81 module C1 = B.C;
82 module D1 = B.C.D
83 module D2 = C1.D
84 module D3 = D2
85
86 module E1 at "http://where"
87 module E2 at "http://where";
88 module E3 = E1
89
90 // Check that ASI does not interfere.
91
92 module X
93 {
94 let x
95 }
96
97 module Y
98 =
99 X
100
101 module Z
102 at
103 "file://local"
104
105 import
106 vx
107 ,
108 vy
109 from
110 B
111
112
113 module Wrap {
114 export
115 x
116 ,
117 y
118
119 var
120 x
121 ,
122 y
123
124 export
125 var
126 v1 = 1
127
128 export
129 let
130 v2 = 2
131
132 export
133 const
134 v3 = 3
135
136 export
137 function
138 f
139 (
140 )
141 {
142 }
143
144 export
145 module V
146 {
147 }
148 }
149
150 export A, A1, A2, A3, B, I, C1, D1, D2, D3, E1, E2, E3, X, Y, Z, Wrap, x, y, UU
151
152
153
154 // Check that 'module' still works as an identifier.
155
156 var module
157 module = {}
158 module["a"] = 6
159 function module() {}
160 function f(module) { return module }
161 try {} catch (module) {}
162
163 module
164 v = 20
165
166
167
168 // Check that module declarations are rejected in eval or local scope.
169
170 module M { export let x; }
171
172 assertThrows("export x;", SyntaxError); // It's using eval, so should throw.
173 assertThrows("export let x;", SyntaxError); 32 assertThrows("export let x;", SyntaxError);
174 assertThrows("import x from M;", SyntaxError); 33 assertThrows("import x from 'http://url';", SyntaxError);
175 assertThrows("module M {};", SyntaxError);
176 34
177 assertThrows("{ export x; }", SyntaxError); 35 assertThrows("{ export x; }", SyntaxError);
178 assertThrows("{ export let x; }", SyntaxError); 36 assertThrows("{ export let x; }", SyntaxError);
179 assertThrows("{ import x from M; }", SyntaxError); 37 assertThrows("{ import x from 'http://url'; }", SyntaxError);
180 assertThrows("{ module M {}; }", SyntaxError);
181 38
182 assertThrows("function f() { export x; }", SyntaxError); 39 assertThrows("function f() { export x; }", SyntaxError);
183 assertThrows("function f() { export let x; }", SyntaxError); 40 assertThrows("function f() { export let x; }", SyntaxError);
184 assertThrows("function f() { import x from M; }", SyntaxError); 41 assertThrows("function f() { import x from 'http://url'; }", SyntaxError);
185 assertThrows("function f() { module M {}; }", SyntaxError);
186 42
187 assertThrows("function f() { { export x; } }", SyntaxError); 43 assertThrows("function f() { { export x; } }", SyntaxError);
188 assertThrows("function f() { { export let x; } }", SyntaxError); 44 assertThrows("function f() { { export let x; } }", SyntaxError);
189 assertThrows("function f() { { import x from M; } }", SyntaxError); 45 assertThrows("function f() { { import x from 'http://url'; } }", SyntaxError);
190 assertThrows("function f() { { module M {}; } }", SyntaxError);
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698