OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // TODO(jmesserly): merge into import_inliner_test.dart. | |
6 // Keeping here for now so it's easier to see the diff. | |
7 part of polymer.test.build.import_inliner_test; | |
8 | |
9 void codeExtractorTests() { | |
10 testPhases('no changes', phases, { | |
11 'a|web/test.html': '<!DOCTYPE html><html></html>', | |
12 }, { | |
13 'a|web/test.html': '<!DOCTYPE html><html></html>', | |
14 }); | |
15 | |
16 testPhases('single script, no library in script', phases, { | |
17 'a|web/test.html': | |
18 '<!DOCTYPE html><html><head>' | |
19 '<script type="application/dart">main() { }</script>', | |
20 }, { | |
21 'a|web/test.html': | |
22 '<!DOCTYPE html><html><head></head><body>' | |
23 '<script type="application/dart" src="test.html.dart"></script>' | |
24 '</body></html>', | |
25 | |
26 'a|web/test.html.dart': | |
27 'library web_test_html;\nmain() { }', | |
28 }); | |
29 | |
30 testPhases('single script, with library', phases, { | |
31 'a|web/test.html': | |
32 '<!DOCTYPE html><html><head>' | |
33 '<script type="application/dart">library f;\nmain() { }</script>', | |
34 }, { | |
35 'a|web/test.html': | |
36 '<!DOCTYPE html><html><head></head><body>' | |
37 '<script type="application/dart" src="test.html.dart"></script>' | |
38 '</body></html>', | |
39 | |
40 'a|web/test.html.dart': | |
41 'library f;\nmain() { }', | |
42 }); | |
43 | |
44 testPhases('under lib/ directory not transformed', phases, { | |
45 'a|lib/test.html': | |
46 '<!DOCTYPE html><html><head>' | |
47 '<script type="application/dart">library f;\nmain() { }</script>', | |
48 }, { | |
49 'a|lib/test.html': | |
50 '<!DOCTYPE html><html><head>' | |
51 '<script type="application/dart">library f;\nmain() { }</script>' | |
52 }); | |
53 | |
54 testPhases('multiple scripts - only emit first', phases, { | |
55 'a|web/test.html': | |
56 '<!DOCTYPE html><html><head>' | |
57 '<script type="application/dart">library a1;\nmain1() { }</script>' | |
58 '<script type="application/dart">library a2;\nmain2() { }</script>', | |
59 }, { | |
60 'a|web/test.html': | |
61 '<!DOCTYPE html><html><head></head><body>' | |
62 '<script type="application/dart" src="test.html.dart"></script>' | |
63 '</body></html>', | |
64 | |
65 'a|web/test.html.dart': | |
66 'library a1;\nmain1() { }', | |
67 }); | |
68 | |
69 testPhases('multiple deeper scripts', phases, { | |
70 'a|web/test.html': | |
71 '<!DOCTYPE html><html><head>' | |
72 '<script type="application/dart">main1() { }</script>' | |
73 '</head><body><div>' | |
74 '<script type="application/dart">main2() { }</script>' | |
75 '</div><div><div>' | |
76 '<script type="application/dart">main3() { }</script>' | |
77 '</div></div>' | |
78 }, { | |
79 'a|web/test.html': | |
80 '<!DOCTYPE html><html><head>' | |
81 '</head><body>' | |
82 '<script type="application/dart" src="test.html.dart"></script>' | |
83 '<div></div><div><div>' | |
84 '</div></div></body></html>', | |
85 | |
86 'a|web/test.html.dart': | |
87 'library web_test_html;\nmain1() { }', | |
88 }); | |
Siggi Cherem (dart-lang)
2014/02/28 01:26:45
to check the issue I broke with the .$counter thin
Jennifer Messerly
2014/02/28 02:21:49
done.
| |
89 | |
90 | |
91 group('fixes import/export/part URIs', dartUriTests); | |
92 } | |
93 | |
94 dartUriTests() { | |
95 | |
96 testPhases('from web folder', phases, { | |
97 'a|web/test.html': | |
98 '<!DOCTYPE html><html><head>' | |
99 '<link rel="import" href="test2/foo.html">' | |
100 '</head><body></body></html>', | |
101 'a|web/test2/foo.html': | |
102 '<!DOCTYPE html><html><head></head><body>' | |
103 '<script type="application/dart">' | |
104 "import 'package:qux/qux.dart';" | |
105 "import 'foo.dart';" | |
106 "export 'bar.dart';" | |
107 "part 'baz.dart';" | |
108 '</script>' | |
109 '</body></html>', | |
110 }, { | |
111 'a|web/test.html': | |
112 '<!DOCTYPE html><html><head></head><body></body></html>', | |
113 'a|web/test.html.scriptUrls': '[["a","web/test.html.dart"]]', | |
114 'a|web/test.html.dart': | |
115 "library web_test_html;\n" | |
116 "import 'package:qux/qux.dart';" | |
117 "import 'test2/foo.dart';" | |
118 "export 'test2/bar.dart';" | |
119 "part 'test2/baz.dart';", | |
120 'a|web/test2/foo.html': | |
121 '<!DOCTYPE html><html><head></head><body>' | |
122 '<script type="application/dart" src="foo.html.dart"></script>' | |
123 '</body></html>', | |
124 'a|web/test2/foo.html.scriptUrls': '[]', | |
125 'a|web/test2/foo.html.dart': | |
126 "library web_test2_foo_html;\n" | |
127 "import 'package:qux/qux.dart';" | |
128 "import 'foo.dart';" | |
129 "export 'bar.dart';" | |
130 "part 'baz.dart';", | |
131 }); | |
132 | |
133 testPhases('from lib folder', phases, { | |
134 'a|web/test.html': | |
135 '<!DOCTYPE html><html><head>' | |
136 '<link rel="import" href="packages/a/test2/foo.html">' | |
137 '</head><body></body></html>', | |
138 'a|lib/test2/foo.html': | |
139 '<!DOCTYPE html><html><head></head><body>' | |
140 '<script type="application/dart">' | |
141 "import 'package:qux/qux.dart';" | |
142 "import 'foo.dart';" | |
143 "export 'bar.dart';" | |
144 "part 'baz.dart';" | |
145 '</script>' | |
146 '</body></html>', | |
147 }, { | |
148 'a|web/test.html': | |
149 '<!DOCTYPE html><html><head></head><body></body></html>', | |
150 'a|web/test.html.scriptUrls': '[["a","web/test.html.dart"]]', | |
151 'a|web/test.html.dart': | |
152 "library web_test_html;\n" | |
153 "import 'package:qux/qux.dart';" | |
154 "import 'package:a/test2/foo.dart';" | |
155 "export 'package:a/test2/bar.dart';" | |
156 "part 'package:a/test2/baz.dart';", | |
157 'a|lib/test2/foo.html': | |
158 '<!DOCTYPE html><html><head></head><body>' | |
159 '<script type="application/dart">' | |
160 "import 'package:qux/qux.dart';" | |
161 "import 'foo.dart';" | |
162 "export 'bar.dart';" | |
163 "part 'baz.dart';" | |
164 '</script>' | |
165 '</body></html>', | |
166 }); | |
167 | |
168 testPhases('from another pkg', phases, { | |
169 'a|web/test.html': | |
170 '<!DOCTYPE html><html><head>' | |
171 '<link rel="import" href="packages/b/test2/foo.html">' | |
172 '</head><body></body></html>', | |
173 'b|lib/test2/foo.html': | |
174 '<!DOCTYPE html><html><head></head><body>' | |
175 '<script type="application/dart">' | |
176 "import 'package:qux/qux.dart';" | |
177 "import 'foo.dart';" | |
178 "export 'bar.dart';" | |
179 "part 'baz.dart';" | |
180 '</script>' | |
181 '</body></html>', | |
182 }, { | |
183 'a|web/test.html': | |
184 '<!DOCTYPE html><html><head></head><body></body></html>', | |
185 'a|web/test.html.scriptUrls': '[["a","web/test.html.dart"]]', | |
186 'a|web/test.html.dart': | |
187 "library web_test_html;\n" | |
188 "import 'package:qux/qux.dart';" | |
189 "import 'package:b/test2/foo.dart';" | |
190 "export 'package:b/test2/bar.dart';" | |
191 "part 'package:b/test2/baz.dart';", | |
192 'b|lib/test2/foo.html': | |
193 '<!DOCTYPE html><html><head></head><body>' | |
194 '<script type="application/dart">' | |
195 "import 'package:qux/qux.dart';" | |
196 "import 'foo.dart';" | |
197 "export 'bar.dart';" | |
198 "part 'baz.dart';" | |
199 '</script>' | |
200 '</body></html>', | |
201 }); | |
202 } | |
OLD | NEW |