OLD | NEW |
---|---|
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 library polymer.test.build.code_extractor_test; | 5 // TODO(jmesserly): merge into import_inliner_test.dart. |
6 // Keeping here for now so it's easier to see the diff. | |
Siggi Cherem (dart-lang)
2014/02/26 22:27:09
nice, thank you :)
| |
7 part of polymer.test.build.import_inliner_test; | |
6 | 8 |
7 import 'package:polymer/src/build/code_extractor.dart'; | 9 void codeExtractorTests() { |
8 import 'package:polymer/src/build/common.dart'; | |
9 import 'package:unittest/compact_vm_config.dart'; | |
10 | |
11 import 'common.dart'; | |
12 | |
13 void main() { | |
14 useCompactVMConfiguration(); | |
15 var phases = [[new InlineCodeExtractor(new TransformOptions())]]; | |
16 | |
17 testPhases('no changes', phases, { | 10 testPhases('no changes', phases, { |
18 'a|web/test.html': '<!DOCTYPE html><html></html>', | 11 'a|web/test.html': '<!DOCTYPE html><html></html>', |
19 }, { | 12 }, { |
20 'a|web/test.html': '<!DOCTYPE html><html></html>', | 13 'a|web/test.html': '<!DOCTYPE html><html></html>', |
21 }); | 14 }); |
22 | 15 |
23 testPhases('single script, no library in script', phases, { | 16 testPhases('single script, no library in script', phases, { |
24 'a|web/test.html': | 17 'a|web/test.html': |
25 '<!DOCTYPE html><html><head>' | 18 '<!DOCTYPE html><html><head>' |
26 '<script type="application/dart">main() { }</script>', | 19 '<script type="application/dart">main() { }</script>', |
27 }, { | 20 }, { |
28 'a|web/test.html': | 21 'a|web/test.html': |
29 '<!DOCTYPE html><html><head>' | 22 '<!DOCTYPE html><html><head></head><body>' |
30 '<script type="application/dart" src="test.html.0.dart"></script>' | 23 '<script type="application/dart" src="test.html.0.dart"></script>' |
31 '</head><body></body></html>', | 24 '</body></html>', |
32 | 25 |
33 'a|web/test.html.0.dart': | 26 'a|web/test.html.0.dart': |
34 'library web_test_html_0;\nmain() { }', | 27 'library web_test_html_0;\nmain() { }', |
35 }); | 28 }); |
36 | 29 |
37 testPhases('single script, with library', phases, { | 30 testPhases('single script, with library', phases, { |
38 'a|web/test.html': | 31 'a|web/test.html': |
39 '<!DOCTYPE html><html><head>' | 32 '<!DOCTYPE html><html><head>' |
40 '<script type="application/dart">library f;\nmain() { }</script>', | 33 '<script type="application/dart">library f;\nmain() { }</script>', |
41 }, { | 34 }, { |
42 'a|web/test.html': | 35 'a|web/test.html': |
43 '<!DOCTYPE html><html><head>' | 36 '<!DOCTYPE html><html><head></head><body>' |
44 '<script type="application/dart" src="test.html.0.dart"></script>' | 37 '<script type="application/dart" src="test.html.0.dart"></script>' |
45 '</head><body></body></html>', | 38 '</body></html>', |
46 | 39 |
47 'a|web/test.html.0.dart': | 40 'a|web/test.html.0.dart': |
48 'library f;\nmain() { }', | 41 'library f;\nmain() { }', |
49 }); | 42 }); |
50 | 43 |
51 testPhases('under lib/ directory also transformed', phases, { | 44 testPhases('under lib/ directory not transformed', phases, { |
52 'a|lib/test.html': | 45 'a|lib/test.html': |
53 '<!DOCTYPE html><html><head>' | 46 '<!DOCTYPE html><html><head>' |
54 '<script type="application/dart">library f;\nmain() { }</script>', | 47 '<script type="application/dart">library f;\nmain() { }</script>', |
55 }, { | 48 }, { |
56 'a|lib/test.html': | 49 'a|lib/test.html': |
57 '<!DOCTYPE html><html><head>' | 50 '<!DOCTYPE html><html><head>' |
58 '<script type="application/dart" src="test.html.0.dart"></script>' | 51 '<script type="application/dart">library f;\nmain() { }</script>' |
59 '</head><body></body></html>', | |
60 | |
61 'a|lib/test.html.0.dart': | |
62 'library f;\nmain() { }', | |
63 }); | 52 }); |
64 | 53 |
65 testPhases('multiple scripts', phases, { | 54 testPhases('multiple scripts - only emit first', phases, { |
66 'a|web/test.html': | 55 'a|web/test.html': |
67 '<!DOCTYPE html><html><head>' | 56 '<!DOCTYPE html><html><head>' |
68 '<script type="application/dart">library a1;\nmain1() { }</script>' | 57 '<script type="application/dart">library a1;\nmain1() { }</script>' |
69 '<script type="application/dart">library a2;\nmain2() { }</script>', | 58 '<script type="application/dart">library a2;\nmain2() { }</script>', |
70 }, { | 59 }, { |
71 'a|web/test.html': | 60 'a|web/test.html': |
72 '<!DOCTYPE html><html><head>' | 61 '<!DOCTYPE html><html><head></head><body>' |
73 '<script type="application/dart" src="test.html.0.dart"></script>' | 62 '<script type="application/dart" src="test.html.0.dart"></script>' |
74 '<script type="application/dart" src="test.html.1.dart"></script>' | 63 '</body></html>', |
75 '</head><body></body></html>', | |
76 | 64 |
77 'a|web/test.html.0.dart': | 65 'a|web/test.html.0.dart': |
78 'library a1;\nmain1() { }', | 66 'library a1;\nmain1() { }', |
79 | |
80 'a|web/test.html.1.dart': | |
81 'library a2;\nmain2() { }', | |
82 }); | 67 }); |
83 | 68 |
84 testPhases('multiple deeper scripts', phases, { | 69 testPhases('multiple deeper scripts', phases, { |
85 'a|web/test.html': | 70 'a|web/test.html': |
86 '<!DOCTYPE html><html><head>' | 71 '<!DOCTYPE html><html><head>' |
87 '<script type="application/dart">main1() { }</script>' | 72 '<script type="application/dart">main1() { }</script>' |
88 '</head><body><div>' | 73 '</head><body><div>' |
89 '<script type="application/dart">main2() { }</script>' | 74 '<script type="application/dart">main2() { }</script>' |
90 '</div><div><div>' | 75 '</div><div><div>' |
91 '<script type="application/dart">main3() { }</script>' | 76 '<script type="application/dart">main3() { }</script>' |
92 '</div></div>' | 77 '</div></div>' |
93 }, { | 78 }, { |
94 'a|web/test.html': | 79 'a|web/test.html': |
95 '<!DOCTYPE html><html><head>' | 80 '<!DOCTYPE html><html><head>' |
81 '</head><body>' | |
96 '<script type="application/dart" src="test.html.0.dart"></script>' | 82 '<script type="application/dart" src="test.html.0.dart"></script>' |
97 '</head><body><div>' | 83 '<div></div><div><div>' |
98 '<script type="application/dart" src="test.html.1.dart"></script>' | |
99 '</div><div><div>' | |
100 '<script type="application/dart" src="test.html.2.dart"></script>' | |
101 '</div></div></body></html>', | 84 '</div></div></body></html>', |
102 | 85 |
103 'a|web/test.html.0.dart': | 86 'a|web/test.html.0.dart': |
104 'library web_test_html_0;\nmain1() { }', | 87 'library web_test_html_0;\nmain1() { }', |
88 }); | |
105 | 89 |
106 'a|web/test.html.1.dart': | 90 testPhases('fixes import/export/part URIs', phases, { |
Siggi Cherem (dart-lang)
2014/02/26 22:27:09
Could we add a similar test that includes files in
Jennifer Messerly
2014/02/27 22:31:40
GOOOOOOD catch! Cross pkg URLs were totally broken
| |
107 'library web_test_html_1;\nmain2() { }', | 91 'a|web/test.html': |
108 | 92 '<!DOCTYPE html><html><head>' |
109 'a|web/test.html.2.dart': | 93 '<link rel="import" href="test2/foo.html">' |
110 'library web_test_html_2;\nmain3() { }', | 94 '</head><body></body></html>', |
95 'a|web/test2/foo.html': | |
96 '<!DOCTYPE html><html><head></head><body>' | |
97 '<script type="application/dart">' | |
98 "import 'foo.dart';" | |
99 "export 'bar.dart';" | |
100 "part 'baz.dart';" | |
101 '</script>' | |
102 '</body></html>', | |
103 }, { | |
104 'a|web/test.html': | |
105 '<!DOCTYPE html><html><head></head><body></body></html>', | |
106 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]', | |
107 'a|web/test.html.0.dart': | |
108 "library web_test_html_0;\n" | |
109 "import 'test2/foo.dart';" | |
110 "export 'test2/bar.dart';" | |
111 "part 'test2/baz.dart';", | |
112 'a|web/test2/foo.html': | |
113 '<!DOCTYPE html><html><head></head><body>' | |
114 '<script type="application/dart" src="foo.html.0.dart"></script>' | |
115 '</body></html>', | |
116 'a|web/test2/foo.html.scriptUrls': '[]', | |
117 'a|web/test2/foo.html.0.dart': | |
118 "library web_test2_foo_html_0;\n" | |
119 "import 'foo.dart';" | |
120 "export 'bar.dart';" | |
121 "part 'baz.dart';", | |
111 }); | 122 }); |
112 } | 123 } |
OLD | NEW |