| 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.transform.code_extractor_test; | 5 library polymer.test.transform.code_extractor_test; |
| 6 | 6 |
| 7 import 'package:polymer/src/transform/code_extractor.dart'; | 7 import 'package:polymer/src/transform/code_extractor.dart'; |
| 8 import 'package:unittest/compact_vm_config.dart'; | 8 import 'package:unittest/compact_vm_config.dart'; |
| 9 | 9 |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 useCompactVMConfiguration(); | 13 useCompactVMConfiguration(); |
| 14 | 14 |
| 15 testPhases('no changes', [[new InlineCodeExtractor()]], { | 15 testPhases('no changes', [[new InlineCodeExtractor()]], { |
| 16 'a|test.html': '<!DOCTYPE html><html></html>', | 16 'a|test.html': '<!DOCTYPE html><html></html>', |
| 17 }, { | 17 }, { |
| 18 'a|test.html': '<!DOCTYPE html><html></html>', | 18 'a|test.html': '<!DOCTYPE html><html></html>', |
| 19 }); | 19 }); |
| 20 | 20 |
| 21 testPhases('single script', [[new InlineCodeExtractor()]], { | 21 testPhases('single script, no lib', [[new InlineCodeExtractor()]], { |
| 22 'a|test.html': | 22 'a|test.html': |
| 23 '<!DOCTYPE html><html><head>' | 23 '<!DOCTYPE html><html><head>' |
| 24 '<script type="application/dart">main() { }</script>', | 24 '<script type="application/dart">main() { }</script>', |
| 25 }, { | 25 }, { |
| 26 'a|test.html': | 26 'a|test.html': |
| 27 '<!DOCTYPE html><html><head>' | 27 '<!DOCTYPE html><html><head>' |
| 28 '<script type="application/dart" src="test.html.0.dart"></script>' | 28 '<script type="application/dart" src="test.html.0.dart"></script>' |
| 29 '</head><body></body></html>', | 29 '</head><body></body></html>', |
| 30 | 30 |
| 31 'a|test.html.0.dart': | 31 'a|test.html.0.dart': |
| 32 'main() { }', | 32 'library test_html_0;\nmain() { }', |
| 33 }); |
| 34 |
| 35 testPhases('single script, with lib', [[new InlineCodeExtractor()]], { |
| 36 'a|test.html': |
| 37 '<!DOCTYPE html><html><head>' |
| 38 '<script type="application/dart">library f;\nmain() { }</script>', |
| 39 }, { |
| 40 'a|test.html': |
| 41 '<!DOCTYPE html><html><head>' |
| 42 '<script type="application/dart" src="test.html.0.dart"></script>' |
| 43 '</head><body></body></html>', |
| 44 |
| 45 'a|test.html.0.dart': |
| 46 'library f;\nmain() { }', |
| 33 }); | 47 }); |
| 34 | 48 |
| 35 testPhases('multiple scripts', [[new InlineCodeExtractor()]], { | 49 testPhases('multiple scripts', [[new InlineCodeExtractor()]], { |
| 36 'a|test.html': | 50 'a|test.html': |
| 37 '<!DOCTYPE html><html><head>' | 51 '<!DOCTYPE html><html><head>' |
| 38 '<script type="application/dart">main1() { }</script>' | 52 '<script type="application/dart">library a1;\nmain1() { }</script>' |
| 39 '<script type="application/dart">main2() { }</script>', | 53 '<script type="application/dart">library a2;\nmain2() { }</script>', |
| 40 }, { | 54 }, { |
| 41 'a|test.html': | 55 'a|test.html': |
| 42 '<!DOCTYPE html><html><head>' | 56 '<!DOCTYPE html><html><head>' |
| 43 '<script type="application/dart" src="test.html.0.dart"></script>' | 57 '<script type="application/dart" src="test.html.0.dart"></script>' |
| 44 '<script type="application/dart" src="test.html.1.dart"></script>' | 58 '<script type="application/dart" src="test.html.1.dart"></script>' |
| 45 '</head><body></body></html>', | 59 '</head><body></body></html>', |
| 46 | 60 |
| 47 'a|test.html.0.dart': | 61 'a|test.html.0.dart': |
| 48 'main1() { }', | 62 'library a1;\nmain1() { }', |
| 49 | 63 |
| 50 'a|test.html.1.dart': | 64 'a|test.html.1.dart': |
| 51 'main2() { }', | 65 'library a2;\nmain2() { }', |
| 52 }); | 66 }); |
| 53 | 67 |
| 54 testPhases('multiple deeper scripts', [[new InlineCodeExtractor()]], { | 68 testPhases('multiple deeper scripts', [[new InlineCodeExtractor()]], { |
| 55 'a|test.html': | 69 'a|test.html': |
| 56 '<!DOCTYPE html><html><head>' | 70 '<!DOCTYPE html><html><head>' |
| 57 '<script type="application/dart">main1() { }</script>' | 71 '<script type="application/dart">main1() { }</script>' |
| 58 '</head><body><div>' | 72 '</head><body><div>' |
| 59 '<script type="application/dart">main2() { }</script>' | 73 '<script type="application/dart">main2() { }</script>' |
| 60 '</div><div><div>' | 74 '</div><div><div>' |
| 61 '<script type="application/dart">main3() { }</script>' | 75 '<script type="application/dart">main3() { }</script>' |
| 62 '</div></div>' | 76 '</div></div>' |
| 63 }, { | 77 }, { |
| 64 'a|test.html': | 78 'a|test.html': |
| 65 '<!DOCTYPE html><html><head>' | 79 '<!DOCTYPE html><html><head>' |
| 66 '<script type="application/dart" src="test.html.0.dart"></script>' | 80 '<script type="application/dart" src="test.html.0.dart"></script>' |
| 67 '</head><body><div>' | 81 '</head><body><div>' |
| 68 '<script type="application/dart" src="test.html.1.dart"></script>' | 82 '<script type="application/dart" src="test.html.1.dart"></script>' |
| 69 '</div><div><div>' | 83 '</div><div><div>' |
| 70 '<script type="application/dart" src="test.html.2.dart"></script>' | 84 '<script type="application/dart" src="test.html.2.dart"></script>' |
| 71 '</div></div></body></html>', | 85 '</div></div></body></html>', |
| 72 | 86 |
| 73 'a|test.html.0.dart': | 87 'a|test.html.0.dart': |
| 74 'main1() { }', | 88 'library test_html_0;\nmain1() { }', |
| 75 | 89 |
| 76 'a|test.html.1.dart': | 90 'a|test.html.1.dart': |
| 77 'main2() { }', | 91 'library test_html_1;\nmain2() { }', |
| 78 | 92 |
| 79 'a|test.html.2.dart': | 93 'a|test.html.2.dart': |
| 80 'main3() { }', | 94 'library test_html_2;\nmain3() { }', |
| 81 }); | 95 }); |
| 82 } | 96 } |
| OLD | NEW |