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

Side by Side Diff: pkg/polymer/test/build/code_extractor.dart

Issue 225043004: Replace bootstrap logic with 'boot.js', use 'component/dart' mime-type and add (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(jmesserly): merge into import_inliner_test.dart. 5 // TODO(jmesserly): merge into import_inliner_test.dart.
6 // Keeping here for now so it's easier to see the diff. 6 // Keeping here for now so it's easier to see the diff.
7 part of polymer.test.build.import_inliner_test; 7 part of polymer.test.build.import_inliner_test;
8 8
9 void codeExtractorTests() { 9 void codeExtractorTests() {
10 testPhases('no changes', phases, { 10 testPhases('no changes', phases, {
11 'a|web/test.html': '<!DOCTYPE html><html></html>', 11 'a|web/test.html': '<!DOCTYPE html><html></html>',
12 }, { 12 }, {
13 'a|web/test.html': '<!DOCTYPE html><html></html>', 13 'a|web/test.html': '<!DOCTYPE html><html></html>',
14 }); 14 });
15 15
16 testPhases('single script, no library in script', phases, { 16 testPhases('single script, no library in script', phases, {
17 'a|web/test.html': 17 'a|web/test.html':
18 '<!DOCTYPE html><html><head>' 18 '<!DOCTYPE html><html><head>'
19 '<script type="application/dart">main() { }</script>', 19 '<script type="application/dart">main() { }</script>',
20 }, { 20 }, {
21 'a|web/test.html': 21 'a|web/test.html':
22 '<!DOCTYPE html><html><head></head><body>' 22 '<!DOCTYPE html><html><head></head><body>'
23 '<script type="application/dart" src="test.html.0.dart"></script>' 23 '<script type="application/dart" src="test.html.0.dart"></script>'
24 '</body></html>', 24 '</body></html>',
25 25
26 'a|web/test.html.0.dart': 26 'a|web/test.html.0.dart':
27 'library a.web.test_html;\nmain() { }', 27 'library a.web.test_html_0;\nmain() { }',
28 });
29
30 testPhases('component script, no library in script', phases, {
31 'a|web/test.html':
32 '<!DOCTYPE html><html><head>'
33 '<script type="component/dart">main() { }</script>',
34 }, {
35 'a|web/test.html':
36 '<!DOCTYPE html><html><head></head><body>'
37 '</body></html>',
38
39 'a|web/test.html.0.dart':
40 'library a.web.test_html_0;\nmain() { }',
28 }); 41 });
29 42
30 testPhases('single script, with library', phases, { 43 testPhases('single script, with library', phases, {
31 'a|web/test.html': 44 'a|web/test.html':
32 '<!DOCTYPE html><html><head>' 45 '<!DOCTYPE html><html><head>'
33 '<script type="application/dart">library f;\nmain() { }</script>', 46 '<script type="application/dart">library f;\nmain() { }</script>',
34 }, { 47 }, {
35 'a|web/test.html': 48 'a|web/test.html':
36 '<!DOCTYPE html><html><head></head><body>' 49 '<!DOCTYPE html><html><head></head><body>'
37 '<script type="application/dart" src="test.html.0.dart"></script>' 50 '<script type="application/dart" src="test.html.0.dart"></script>'
38 '</body></html>', 51 '</body></html>',
39 52
40 'a|web/test.html.0.dart': 53 'a|web/test.html.0.dart':
41 'library f;\nmain() { }', 54 'library f;\nmain() { }',
42 }); 55 });
43 56
44 testPhases('under lib/ directory not transformed', phases, { 57 testPhases('under lib/ directory not transformed', phases, {
45 'a|lib/test.html': 58 'a|lib/test.html':
46 '<!DOCTYPE html><html><head>' 59 '<!DOCTYPE html><html><head>'
47 '<script type="application/dart">library f;\nmain() { }</script>', 60 '<script type="application/dart">library f;\nmain() { }</script>'
61 '<script type="component/dart">library g;\nmain() { }</script>',
48 }, { 62 }, {
49 'a|lib/test.html': 63 'a|lib/test.html':
50 '<!DOCTYPE html><html><head>' 64 '<!DOCTYPE html><html><head>'
51 '<script type="application/dart">library f;\nmain() { }</script>' 65 '<script type="application/dart">library f;\nmain() { }</script>'
66 '<script type="component/dart">library g;\nmain() { }</script>',
52 }); 67 });
53 68
54 testPhases('multiple scripts - only emit first', phases, { 69 testPhases('multiple scripts allowed', phases, {
55 'a|web/test.html': 70 'a|web/test.html':
56 '<!DOCTYPE html><html><head>' 71 '<!DOCTYPE html><html><head>'
57 '<script type="application/dart">library a1;\nmain1() { }</script>' 72 '<script type="application/dart">library a1;\nmain1() { }</script>'
58 '<script type="application/dart">library a2;\nmain2() { }</script>', 73 '<script type="application/dart">library a2;\nmain2() { }</script>',
59 }, { 74 }, {
60 'a|web/test.html': 75 'a|web/test.html':
61 '<!DOCTYPE html><html><head></head><body>' 76 '<!DOCTYPE html><html><head></head><body>'
62 '<script type="application/dart" src="test.html.0.dart"></script>' 77 '<script type="application/dart" src="test.html.0.dart"></script>'
78 '<script type="application/dart" src="test.html.1.dart"></script>'
63 '</body></html>', 79 '</body></html>',
64 80
65 'a|web/test.html.0.dart': 81 'a|web/test.html.0.dart':
66 'library a1;\nmain1() { }', 82 'library a1;\nmain1() { }',
83 'a|web/test.html.1.dart':
84 'library a2;\nmain2() { }',
85 });
86
87 testPhases('component scripts removed', phases, {
88 'a|web/test.html':
89 '<!DOCTYPE html><html><head>'
90 '<script type="component/dart">library a1;\nmain1() { }</script>'
91 '<script type="component/dart">library a2;\nmain2() { }</script>',
92 }, {
93 'a|web/test.html':
94 '<!DOCTYPE html><html><head></head><body>'
95 '</body></html>',
96 'a|web/test.html.scriptUrls': JSON.encode([
97 ["a", "web/test.html.0.dart"],
98 ["a", "web/test.html.1.dart"]]),
99 'a|web/test.html.0.dart':
100 'library a1;\nmain1() { }',
101 'a|web/test.html.1.dart':
102 'library a2;\nmain2() { }',
67 }); 103 });
68 104
69 testPhases('multiple deeper scripts', phases, { 105 testPhases('multiple deeper scripts', phases, {
70 'a|web/test.html': 106 'a|web/test.html':
71 '<!DOCTYPE html><html><head>' 107 '<!DOCTYPE html><html><head>'
72 '<script type="application/dart">main1() { }</script>' 108 '<script type="application/dart">main1() { }</script>'
73 '</head><body><div>' 109 '</head><body><div>'
74 '<script type="application/dart">main2() { }</script>' 110 '<script type="application/dart">main2() { }</script>'
75 '</div><div><div>' 111 '</div><div><div>'
76 '<script type="application/dart">main3() { }</script>' 112 '<script type="application/dart">main3() { }</script>'
77 '</div></div>' 113 '</div></div>'
78 }, { 114 }, {
79 'a|web/test.html': 115 'a|web/test.html':
80 '<!DOCTYPE html><html><head>' 116 '<!DOCTYPE html><html><head>'
81 '</head><body>' 117 '</head><body>'
82 '<script type="application/dart" src="test.html.0.dart"></script>' 118 '<script type="application/dart" src="test.html.0.dart"></script>'
83 '<div></div><div><div>' 119 '<div>'
120 '<script type="application/dart" src="test.html.1.dart"></script>'
121 '</div><div><div>'
122 '<script type="application/dart" src="test.html.2.dart"></script>'
84 '</div></div></body></html>', 123 '</div></div></body></html>',
85 124
86 'a|web/test.html.0.dart': 125 'a|web/test.html.0.dart':
87 'library a.web.test_html;\nmain1() { }', 126 'library a.web.test_html_0;\nmain1() { }',
127 'a|web/test.html.1.dart':
128 'library a.web.test_html_1;\nmain2() { }',
129 'a|web/test.html.2.dart':
130 'library a.web.test_html_2;\nmain3() { }',
88 }); 131 });
89 132
90 testPhases('multiple imported scripts', phases, { 133 testPhases('multiple imported scripts', phases, {
91 'a|web/test.html': 134 'a|web/test.html':
92 '<link rel="import" href="test2.html">' 135 '<link rel="import" href="test2.html">'
93 '<link rel="import" href="bar/test.html">' 136 '<link rel="import" href="bar/test.html">'
94 '<link rel="import" href="packages/a/foo/test.html">' 137 '<link rel="import" href="packages/a/foo/test.html">'
95 '<link rel="import" href="packages/b/test.html">', 138 '<link rel="import" href="packages/b/test.html">',
96 'a|web/test2.html': 139 'a|web/test2.html':
97 '<script type="application/dart">main1() { }', 140 '<script type="component/dart">main1() { }',
98 'a|web/bar/test.html': 141 'a|web/bar/test.html':
99 '<script type="application/dart">main2() { }', 142 '<script type="component/dart">main2() { }',
100 'a|lib/foo/test.html': 143 'a|lib/foo/test.html':
101 '<script type="application/dart">main3() { }', 144 '<script type="component/dart">main3() { }',
102 'b|lib/test.html': 145 'b|lib/test.html':
103 '<script type="application/dart">main4() { }' 146 '<script type="component/dart">main4() { }'
104 }, { 147 }, {
105 'a|web/test.html': 148 'a|web/test.html':
106 '<html><head></head><body></body></html>', 149 '<html><head></head><body></body></html>',
107 'a|web/test.html.scriptUrls': JSON.encode([ 150 'a|web/test.html.scriptUrls': JSON.encode([
108 ["a", "web/test.html.0.dart"], 151 ["a", "web/test.html.0.dart"],
109 ["a", "web/test.html.1.dart"], 152 ["a", "web/test.html.1.dart"],
110 ["a", "web/test.html.2.dart"], 153 ["a", "web/test.html.2.dart"],
111 ["a", "web/test.html.3.dart"], 154 ["a", "web/test.html.3.dart"],
112 ]), 155 ]),
113 'a|web/test.html.0.dart': 'library a.web.test2_html;\nmain1() { }', 156 'a|web/test.html.0.dart': 'library a.web.test2_html_0;\nmain1() { }',
114 'a|web/test.html.1.dart': 'library a.web.bar.test_html;\nmain2() { }', 157 'a|web/test.html.1.dart': 'library a.web.bar.test_html_1;\nmain2() { }',
115 'a|web/test.html.2.dart': 'library a.foo.test_html;\nmain3() { }', 158 'a|web/test.html.2.dart': 'library a.foo.test_html_2;\nmain3() { }',
116 'a|web/test.html.3.dart': 'library b.test_html;\nmain4() { }' 159 'a|web/test.html.3.dart': 'library b.test_html_3;\nmain4() { }'
117 }); 160 });
118 161
119 group('fixes import/export/part URIs', dartUriTests); 162 group('fixes import/export/part URIs', dartUriTests);
120 } 163 }
121 164
122 dartUriTests() { 165 dartUriTests() {
123 166
124 testPhases('from web folder', phases, { 167 testPhases('from web folder', phases, {
125 'a|web/test.html': 168 'a|web/test.html':
126 '<!DOCTYPE html><html><head>' 169 '<!DOCTYPE html><html><head>'
127 '<link rel="import" href="test2/foo.html">' 170 '<link rel="import" href="test2/foo.html">'
128 '</head><body></body></html>', 171 '</head><body></body></html>',
129 'a|web/test2/foo.html': 172 'a|web/test2/foo.html':
130 '<!DOCTYPE html><html><head></head><body>' 173 '<!DOCTYPE html><html><head></head><body>'
131 '<script type="application/dart">' 174 '<script type="application/dart">'
132 "import 'package:qux/qux.dart';" 175 "import 'package:qux/qux.dart';"
133 "import 'foo.dart';" 176 "import 'foo.dart';"
134 "export 'bar.dart';" 177 "export 'bar.dart';"
135 "part 'baz.dart';" 178 "part 'baz.dart';"
136 '</script>' 179 '</script>'
137 '</body></html>', 180 '</body></html>',
138 }, { 181 }, {
139 'a|web/test.html': 182 'a|web/test.html':
140 '<!DOCTYPE html><html><head></head><body></body></html>', 183 '<!DOCTYPE html><html><head></head><body>'
141 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', 184 '<script type="application/dart" src="test.html.0.dart"></script>'
185 '</body></html>',
186 'a|web/test.html.scriptUrls': '[]',
142 'a|web/test.html.0.dart': 187 'a|web/test.html.0.dart':
143 "library a.web.test2.foo_html;\n" 188 "library a.web.test2.foo_html_0;\n"
144 "import 'package:qux/qux.dart';" 189 "import 'package:qux/qux.dart';"
145 "import 'test2/foo.dart';" 190 "import 'test2/foo.dart';"
146 "export 'test2/bar.dart';" 191 "export 'test2/bar.dart';"
147 "part 'test2/baz.dart';", 192 "part 'test2/baz.dart';",
148 'a|web/test2/foo.html': 193 'a|web/test2/foo.html':
149 '<!DOCTYPE html><html><head></head><body>' 194 '<!DOCTYPE html><html><head></head><body>'
150 '<script type="application/dart" src="foo.html.0.dart"></script>' 195 '<script type="application/dart" src="foo.html.0.dart"></script>'
151 '</body></html>', 196 '</body></html>',
152 'a|web/test2/foo.html.scriptUrls': '[]', 197 'a|web/test2/foo.html.scriptUrls': '[]',
153 'a|web/test2/foo.html.0.dart': 198 'a|web/test2/foo.html.0.dart':
154 "library a.web.test2.foo_html;\n" 199 "library a.web.test2.foo_html_0;\n"
155 "import 'package:qux/qux.dart';" 200 "import 'package:qux/qux.dart';"
156 "import 'foo.dart';" 201 "import 'foo.dart';"
157 "export 'bar.dart';" 202 "export 'bar.dart';"
203 "part 'baz.dart';",
204 });
205
206 testPhases('from web folder, component', phases, {
207 'a|web/test.html':
208 '<!DOCTYPE html><html><head>'
209 '<link rel="import" href="test2/foo.html">'
210 '</head><body></body></html>',
211 'a|web/test2/foo.html':
212 '<!DOCTYPE html><html><head></head><body>'
213 '<script type="component/dart">'
214 "import 'package:qux/qux.dart';"
215 "import 'foo.dart';"
216 "export 'bar.dart';"
217 "part 'baz.dart';"
218 '</script>'
219 '</body></html>',
220 }, {
221 'a|web/test.html':
222 '<!DOCTYPE html><html><head></head><body></body></html>',
223 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]',
224 'a|web/test.html.0.dart':
225 "library a.web.test2.foo_html_0;\n"
226 "import 'package:qux/qux.dart';"
227 "import 'test2/foo.dart';"
228 "export 'test2/bar.dart';"
229 "part 'test2/baz.dart';",
230 'a|web/test2/foo.html':
231 '<!DOCTYPE html><html><head></head><body></body></html>',
232 'a|web/test2/foo.html.scriptUrls': '[["a","web/test2/foo.html.0.dart"]]',
233 'a|web/test2/foo.html.0.dart':
234 "library a.web.test2.foo_html_0;\n"
235 "import 'package:qux/qux.dart';"
236 "import 'foo.dart';"
237 "export 'bar.dart';"
158 "part 'baz.dart';", 238 "part 'baz.dart';",
159 }); 239 });
160 240
161 testPhases('from lib folder', phases, { 241 testPhases('from lib folder', phases, {
162 'a|web/test.html': 242 'a|web/test.html':
163 '<!DOCTYPE html><html><head>' 243 '<!DOCTYPE html><html><head>'
164 '<link rel="import" href="packages/a/test2/foo.html">' 244 '<link rel="import" href="packages/a/test2/foo.html">'
165 '</head><body></body></html>', 245 '</head><body></body></html>',
166 'a|lib/test2/foo.html': 246 'a|lib/test2/foo.html':
167 '<!DOCTYPE html><html><head></head><body>' 247 '<!DOCTYPE html><html><head></head><body>'
168 '<script type="application/dart">' 248 '<script type="component/dart">'
169 "import 'package:qux/qux.dart';" 249 "import 'package:qux/qux.dart';"
170 "import 'foo.dart';" 250 "import 'foo.dart';"
171 "export 'bar.dart';" 251 "export 'bar.dart';"
172 "part 'baz.dart';" 252 "part 'baz.dart';"
173 '</script>' 253 '</script>'
174 '</body></html>', 254 '</body></html>',
175 }, { 255 }, {
176 'a|web/test.html': 256 'a|web/test.html':
177 '<!DOCTYPE html><html><head></head><body></body></html>', 257 '<!DOCTYPE html><html><head></head><body></body></html>',
178 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', 258 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]',
179 'a|web/test.html.0.dart': 259 'a|web/test.html.0.dart':
180 "library a.test2.foo_html;\n" 260 "library a.test2.foo_html_0;\n"
181 "import 'package:qux/qux.dart';" 261 "import 'package:qux/qux.dart';"
182 "import 'package:a/test2/foo.dart';" 262 "import 'package:a/test2/foo.dart';"
183 "export 'package:a/test2/bar.dart';" 263 "export 'package:a/test2/bar.dart';"
184 "part 'package:a/test2/baz.dart';", 264 "part 'package:a/test2/baz.dart';",
185 'a|lib/test2/foo.html': 265 'a|lib/test2/foo.html':
186 '<!DOCTYPE html><html><head></head><body>' 266 '<!DOCTYPE html><html><head></head><body>'
187 '<script type="application/dart">' 267 '<script type="component/dart">'
188 "import 'package:qux/qux.dart';" 268 "import 'package:qux/qux.dart';"
189 "import 'foo.dart';" 269 "import 'foo.dart';"
190 "export 'bar.dart';" 270 "export 'bar.dart';"
191 "part 'baz.dart';" 271 "part 'baz.dart';"
192 '</script>' 272 '</script>'
193 '</body></html>', 273 '</body></html>',
194 }); 274 });
195 275
196 testPhases('from another pkg', phases, { 276 testPhases('from another pkg', phases, {
197 'a|web/test.html': 277 'a|web/test.html':
198 '<!DOCTYPE html><html><head>' 278 '<!DOCTYPE html><html><head>'
199 '<link rel="import" href="packages/b/test2/foo.html">' 279 '<link rel="import" href="packages/b/test2/foo.html">'
200 '</head><body></body></html>', 280 '</head><body></body></html>',
201 'b|lib/test2/foo.html': 281 'b|lib/test2/foo.html':
202 '<!DOCTYPE html><html><head></head><body>' 282 '<!DOCTYPE html><html><head></head><body>'
203 '<script type="application/dart">' 283 '<script type="component/dart">'
204 "import 'package:qux/qux.dart';" 284 "import 'package:qux/qux.dart';"
205 "import 'foo.dart';" 285 "import 'foo.dart';"
206 "export 'bar.dart';" 286 "export 'bar.dart';"
207 "part 'baz.dart';" 287 "part 'baz.dart';"
208 '</script>' 288 '</script>'
209 '</body></html>', 289 '</body></html>',
210 }, { 290 }, {
211 'a|web/test.html': 291 'a|web/test.html':
212 '<!DOCTYPE html><html><head></head><body></body></html>', 292 '<!DOCTYPE html><html><head></head><body></body></html>',
213 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', 293 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]',
214 'a|web/test.html.0.dart': 294 'a|web/test.html.0.dart':
215 "library b.test2.foo_html;\n" 295 "library b.test2.foo_html_0;\n"
216 "import 'package:qux/qux.dart';" 296 "import 'package:qux/qux.dart';"
217 "import 'package:b/test2/foo.dart';" 297 "import 'package:b/test2/foo.dart';"
218 "export 'package:b/test2/bar.dart';" 298 "export 'package:b/test2/bar.dart';"
219 "part 'package:b/test2/baz.dart';", 299 "part 'package:b/test2/baz.dart';",
220 'b|lib/test2/foo.html': 300 'b|lib/test2/foo.html':
221 '<!DOCTYPE html><html><head></head><body>' 301 '<!DOCTYPE html><html><head></head><body>'
222 '<script type="application/dart">' 302 '<script type="component/dart">'
223 "import 'package:qux/qux.dart';" 303 "import 'package:qux/qux.dart';"
224 "import 'foo.dart';" 304 "import 'foo.dart';"
225 "export 'bar.dart';" 305 "export 'bar.dart';"
226 "part 'baz.dart';" 306 "part 'baz.dart';"
227 '</script>' 307 '</script>'
228 '</body></html>', 308 '</body></html>',
229 }); 309 });
230 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698