| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library web_components.test.build.script_compactor_test; | 4 library web_components.test.build.script_compactor_test; |
| 5 | 5 |
| 6 import 'package:code_transformers/tests.dart'; | 6 import 'package:code_transformers/tests.dart'; |
| 7 import 'package:web_components/build/messages.dart'; | 7 import 'package:web_components/build/messages.dart'; |
| 8 import 'package:web_components/build/script_compactor.dart'; | 8 import 'package:web_components/build/script_compactor.dart'; |
| 9 import 'package:unittest/compact_vm_config.dart'; | 9 import 'package:unittest/compact_vm_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 }, { | 33 }, { |
| 34 'a|web/index.html': ''' | 34 'a|web/index.html': ''' |
| 35 <!DOCTYPE html><html><head></head><body> | 35 <!DOCTYPE html><html><head></head><body> |
| 36 <script type="application/dart" src="index.bootstrap.dart"></script> | 36 <script type="application/dart" src="index.bootstrap.dart"></script> |
| 37 </body></html>''', | 37 </body></html>''', |
| 38 'a|web/index.bootstrap.dart': ''' | 38 'a|web/index.bootstrap.dart': ''' |
| 39 library a.web.index_bootstrap_dart; | 39 library a.web.index_bootstrap_dart; |
| 40 | 40 |
| 41 import 'index.dart' as i0; | 41 import 'index.dart' as i0; |
| 42 | 42 |
| 43 void main() => i0.main();''', | 43 void main() { i0.main(); }''', |
| 44 'a|web/index.dart': ''' | 44 'a|web/index.dart': ''' |
| 45 library a.index; | 45 library a.index; |
| 46 main(){}''', | 46 main(){}''', |
| 47 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 47 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 48 | 48 |
| 49 testPhases('multiple scripts from nested html import', phases, { | 49 testPhases('multiple scripts from nested html import', phases, { |
| 50 'a|web/index.html': ''' | 50 'a|web/index.html': ''' |
| 51 <!DOCTYPE html><html> | 51 <!DOCTYPE html><html> |
| 52 <head> | 52 <head> |
| 53 <link rel="import" href="packages/b/a.html"> | 53 <link rel="import" href="packages/b/a.html"> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 78 <script type="application/dart" src="index.bootstrap.dart"></script> | 78 <script type="application/dart" src="index.bootstrap.dart"></script> |
| 79 </body></html>''', | 79 </body></html>''', |
| 80 'a|web/index.bootstrap.dart': ''' | 80 'a|web/index.bootstrap.dart': ''' |
| 81 library a.web.index_bootstrap_dart; | 81 library a.web.index_bootstrap_dart; |
| 82 | 82 |
| 83 import 'package:b/b/b.dart' as i0; | 83 import 'package:b/b/b.dart' as i0; |
| 84 import 'package:c/c.dart' as i1; | 84 import 'package:c/c.dart' as i1; |
| 85 import 'package:b/a.dart' as i2; | 85 import 'package:b/a.dart' as i2; |
| 86 import 'index.dart' as i3; | 86 import 'index.dart' as i3; |
| 87 | 87 |
| 88 void main() => i3.main();''', | 88 void main() { i3.main(); }''', |
| 89 'b|lib/a.html': ''' | 89 'b|lib/a.html': ''' |
| 90 <link rel="import" href="b/b.html"> | 90 <link rel="import" href="b/b.html"> |
| 91 <link rel="import" href="../../packages/c/c.html"> | 91 <link rel="import" href="../../packages/c/c.html"> |
| 92 <script type="application/dart" src="a.dart"></script>''', | 92 <script type="application/dart" src="a.dart"></script>''', |
| 93 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 93 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 94 | 94 |
| 95 testPhases('inline scripts', phases, { | 95 testPhases('inline scripts', phases, { |
| 96 'a|web/index.html': ''' | 96 'a|web/index.html': ''' |
| 97 <!DOCTYPE html> | 97 <!DOCTYPE html> |
| 98 <html> | 98 <html> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 129 'a|web/index.html.0.dart': ''' | 129 'a|web/index.html.0.dart': ''' |
| 130 library a.foo; | 130 library a.foo; |
| 131 | 131 |
| 132 import 'package:a/bar.dart';''', | 132 import 'package:a/bar.dart';''', |
| 133 'a|web/index.html.1.bootstrap.dart': ''' | 133 'a|web/index.html.1.bootstrap.dart': ''' |
| 134 library a.web.index_html_1_bootstrap_dart; | 134 library a.web.index_html_1_bootstrap_dart; |
| 135 | 135 |
| 136 import 'index.html.0.dart' as i0; | 136 import 'index.html.0.dart' as i0; |
| 137 import 'index.html.1.dart' as i1; | 137 import 'index.html.1.dart' as i1; |
| 138 | 138 |
| 139 void main() => i1.main();''', | 139 void main() { i1.main(); }''', |
| 140 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 140 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 141 | 141 |
| 142 testPhases('Cleans library names generated from file paths.', phases, { | 142 testPhases('Cleans library names generated from file paths.', phases, { |
| 143 'a|web/01_test.html': ''' | 143 'a|web/01_test.html': ''' |
| 144 <!DOCTYPE html><html><head> | 144 <!DOCTYPE html><html><head> |
| 145 <script type="application/dart">/*1*/</script> | 145 <script type="application/dart">/*1*/</script> |
| 146 </head></html>''', | 146 </head></html>''', |
| 147 'a|web/foo_02_test.html': ''' | 147 'a|web/foo_02_test.html': ''' |
| 148 <!DOCTYPE html><html><head> | 148 <!DOCTYPE html><html><head> |
| 149 <script type="application/dart">/*2*/</script> | 149 <script type="application/dart">/*2*/</script> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 </script> | 194 </script> |
| 195 </head><body></body></html>''', | 195 </head><body></body></html>''', |
| 196 'a|web/test.html.0.dart': ''' | 196 'a|web/test.html.0.dart': ''' |
| 197 library a.web.test_html_0; | 197 library a.web.test_html_0; |
| 198 main() { }''', | 198 main() { }''', |
| 199 'a|web/test.html.0.bootstrap.dart': ''' | 199 'a|web/test.html.0.bootstrap.dart': ''' |
| 200 library a.web.test_html_0_bootstrap_dart; | 200 library a.web.test_html_0_bootstrap_dart; |
| 201 | 201 |
| 202 import 'test.html.0.dart' as i0; | 202 import 'test.html.0.dart' as i0; |
| 203 | 203 |
| 204 void main() => i0.main();''', | 204 void main() { i0.main(); }''', |
| 205 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 205 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 206 | 206 |
| 207 testPhases('single script, with library', phases, { | 207 testPhases('single script, with library', phases, { |
| 208 'a|web/test.html': ''' | 208 'a|web/test.html': ''' |
| 209 <!DOCTYPE html><html><head> | 209 <!DOCTYPE html><html><head> |
| 210 <script type="application/dart"> | 210 <script type="application/dart"> |
| 211 library f; | 211 library f; |
| 212 main() { } | 212 main() { } |
| 213 </script>''', | 213 </script>''', |
| 214 }, { | 214 }, { |
| 215 'a|web/test.html': ''' | 215 'a|web/test.html': ''' |
| 216 <!DOCTYPE html><html><head> | 216 <!DOCTYPE html><html><head> |
| 217 <script type="application/dart" src="test.html.0.bootstrap.dart"> | 217 <script type="application/dart" src="test.html.0.bootstrap.dart"> |
| 218 </script> | 218 </script> |
| 219 </head><body></body></html>''', | 219 </head><body></body></html>''', |
| 220 'a|web/test.html.0.dart': ''' | 220 'a|web/test.html.0.dart': ''' |
| 221 library f; | 221 library f; |
| 222 main() { }''', | 222 main() { }''', |
| 223 'a|web/test.html.0.bootstrap.dart': ''' | 223 'a|web/test.html.0.bootstrap.dart': ''' |
| 224 library a.web.test_html_0_bootstrap_dart; | 224 library a.web.test_html_0_bootstrap_dart; |
| 225 | 225 |
| 226 import 'test.html.0.dart' as i0; | 226 import 'test.html.0.dart' as i0; |
| 227 | 227 |
| 228 void main() => i0.main();''', | 228 void main() { i0.main(); }''', |
| 229 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 229 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 230 | 230 |
| 231 testPhases('under lib/ directory not transformed', phases, { | 231 testPhases('under lib/ directory not transformed', phases, { |
| 232 'a|lib/test.html': ''' | 232 'a|lib/test.html': ''' |
| 233 <!DOCTYPE html><html><head> | 233 <!DOCTYPE html><html><head> |
| 234 <script type="application/dart"> | 234 <script type="application/dart"> |
| 235 library f; | 235 library f; |
| 236 main() { } | 236 main() { } |
| 237 </script>''', | 237 </script>''', |
| 238 }, { | 238 }, { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 <script type="application/dart" src="test.bootstrap.dart"></script> | 280 <script type="application/dart" src="test.bootstrap.dart"></script> |
| 281 </head><body></body></html>''', | 281 </head><body></body></html>''', |
| 282 'a|web/test.bootstrap.dart': ''' | 282 'a|web/test.bootstrap.dart': ''' |
| 283 library a.web.test_bootstrap_dart; | 283 library a.web.test_bootstrap_dart; |
| 284 import 'test.html.0.dart' as i0; | 284 import 'test.html.0.dart' as i0; |
| 285 import 'test.html.1.dart' as i1; | 285 import 'test.html.1.dart' as i1; |
| 286 import 'test.html.2.dart' as i2; | 286 import 'test.html.2.dart' as i2; |
| 287 import 'test.html.3.dart' as i3; | 287 import 'test.html.3.dart' as i3; |
| 288 import 'test.dart' as i4; | 288 import 'test.dart' as i4; |
| 289 | 289 |
| 290 void main() => i4.main(); | 290 void main() { i4.main(); } |
| 291 ''', | 291 ''', |
| 292 'a|web/test.html.0.dart': ''' | 292 'a|web/test.html.0.dart': ''' |
| 293 library a.web.test_html_0; | 293 library a.web.test_html_0; |
| 294 main1() { }''', | 294 main1() { }''', |
| 295 'a|web/test.html.1.dart': ''' | 295 'a|web/test.html.1.dart': ''' |
| 296 library a.web.test_html_1; | 296 library a.web.test_html_1; |
| 297 main2() { }''', | 297 main2() { }''', |
| 298 'a|web/test.html.2.dart': ''' | 298 'a|web/test.html.2.dart': ''' |
| 299 library a.web.test_html_2; | 299 library a.web.test_html_2; |
| 300 main3() { }''', | 300 main3() { }''', |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 testPhases('script src is invalid', phases, { | 424 testPhases('script src is invalid', phases, { |
| 425 'a|web/test.html': ''' | 425 'a|web/test.html': ''' |
| 426 <!DOCTYPE html><html><body> | 426 <!DOCTYPE html><html><body> |
| 427 <script type="application/dart" src="a.dart"></script> | 427 <script type="application/dart" src="a.dart"></script> |
| 428 </body></html>''', | 428 </body></html>''', |
| 429 }, {}, [ | 429 }, {}, [ |
| 430 'warning: ${scriptFileNotFound.create({'url': 'a|web/a.dart'}).snippet} ' | 430 'warning: ${scriptFileNotFound.create({'url': 'a|web/a.dart'}).snippet} ' |
| 431 '(web/test.html 1 8)', | 431 '(web/test.html 1 8)', |
| 432 ]); | 432 ]); |
| 433 } | 433 } |
| OLD | NEW |