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