| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 import 'bar.dart'; | 113 import 'bar.dart'; |
| 114 </script>''', | 114 </script>''', |
| 115 }, { | 115 }, { |
| 116 'a|web/index.html': ''' | 116 'a|web/index.html': ''' |
| 117 <!DOCTYPE html> | 117 <!DOCTYPE html> |
| 118 <html> | 118 <html> |
| 119 <head> | 119 <head> |
| 120 <link rel="import" href="packages/a/foo.html"> | 120 <link rel="import" href="packages/a/foo.html"> |
| 121 </head> | 121 </head> |
| 122 <body> | 122 <body> |
| 123 <script type="application/dart" src="index.html.1.bootstrap.dart"></
script> | 123 <script type="application/dart" src="index.bootstrap.dart"></script> |
| 124 </body> | 124 </body> |
| 125 </html>''', | 125 </html>''', |
| 126 'a|web/index.html.1.dart': ''' | 126 'a|web/index.html.1.dart': ''' |
| 127 library a.index; | 127 library a.index; |
| 128 main(){}''', | 128 main(){}''', |
| 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.bootstrap.dart': ''' |
| 134 library a.web.index_html_1_bootstrap_dart; | 134 library a.web.index_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> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 '`web/test.html`. Exactly one was expected.', | 183 '`web/test.html`. Exactly one was expected.', |
| 184 ], StringFormatter.noNewlinesOrSurroundingWhitespace); | 184 ], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| 185 | 185 |
| 186 testPhases('single script, no library in script', phases, { | 186 testPhases('single script, no library in script', phases, { |
| 187 'a|web/test.html': ''' | 187 'a|web/test.html': ''' |
| 188 <!DOCTYPE html><html><head> | 188 <!DOCTYPE html><html><head> |
| 189 <script type="application/dart">main() { }</script>''', | 189 <script type="application/dart">main() { }</script>''', |
| 190 }, { | 190 }, { |
| 191 'a|web/test.html': ''' | 191 'a|web/test.html': ''' |
| 192 <!DOCTYPE html><html><head> | 192 <!DOCTYPE html><html><head> |
| 193 <script type="application/dart" src="test.html.0.bootstrap.dart"> | 193 <script type="application/dart" src="test.bootstrap.dart"> |
| 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.bootstrap.dart': ''' |
| 200 library a.web.test_html_0_bootstrap_dart; | 200 library a.web.test_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.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.bootstrap.dart': ''' |
| 224 library a.web.test_html_0_bootstrap_dart; | 224 library a.web.test_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"> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 </head><body></body></html>''', | 329 </head><body></body></html>''', |
| 330 'a|web/test.html.0.dart': ''' | 330 'a|web/test.html.0.dart': ''' |
| 331 library a.web.test_html_0; | 331 library a.web.test_html_0; |
| 332 | 332 |
| 333 import 'package:qux/qux.dart'; | 333 import 'package:qux/qux.dart'; |
| 334 import 'test2/foo.dart'; | 334 import 'test2/foo.dart'; |
| 335 export 'test2/bar.dart'; | 335 export 'test2/bar.dart'; |
| 336 part 'test2/baz.dart';''', | 336 part 'test2/baz.dart';''', |
| 337 'a|web/test2/foo.html': ''' | 337 'a|web/test2/foo.html': ''' |
| 338 <!DOCTYPE html><html><head></head><body> | 338 <!DOCTYPE html><html><head></head><body> |
| 339 <script type="application/dart" src="foo.html.0.bootstrap.dart"> | 339 <script type="application/dart" src="foo.bootstrap.dart"> |
| 340 </script> | 340 </script> |
| 341 </body></html>''', | 341 </body></html>''', |
| 342 'a|web/test2/foo.html.0.dart': ''' | 342 'a|web/test2/foo.html.0.dart': ''' |
| 343 library a.web.test2.foo_html_0; | 343 library a.web.test2.foo_html_0; |
| 344 | 344 |
| 345 import 'package:qux/qux.dart'; | 345 import 'package:qux/qux.dart'; |
| 346 import 'foo.dart'; | 346 import 'foo.dart'; |
| 347 export 'bar.dart'; | 347 export 'bar.dart'; |
| 348 part 'baz.dart';''', | 348 part 'baz.dart';''', |
| 349 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); | 349 }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); |
| (...skipping 74 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 |