| 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.script_compactor_test; | 5 library polymer.test.transform.script_compactor_test; |
| 6 | 6 |
| 7 import 'package:polymer/src/transform/script_compactor.dart'; | 7 import 'package:polymer/src/transform/script_compactor.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 ScriptCompactor()]], { | 15 testPhases('no changes', [[new ScriptCompactor()]], { |
| 16 'a|test.html': '<!DOCTYPE html><html></html>', | 16 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 17 }, { | 17 }, { |
| 18 'a|test.html': '<!DOCTYPE html><html></html>', | 18 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 19 }); |
| 20 |
| 21 testPhases('no changes outside web/', [[new ScriptCompactor()]], { |
| 22 'a|lib/test.html': |
| 23 '<!DOCTYPE html><html><head>' |
| 24 '<script type="application/dart" src="a.dart"></script>', |
| 25 }, { |
| 26 'a|lib/test.html': |
| 27 '<!DOCTYPE html><html><head>' |
| 28 '<script type="application/dart" src="a.dart"></script>', |
| 19 }); | 29 }); |
| 20 | 30 |
| 21 testPhases('single script', [[new ScriptCompactor()]], { | 31 testPhases('single script', [[new ScriptCompactor()]], { |
| 22 'a|test.html': | 32 'a|web/test.html': |
| 23 '<!DOCTYPE html><html><head>' | 33 '<!DOCTYPE html><html><head>' |
| 24 '<script type="application/dart" src="a.dart"></script>', | 34 '<script type="application/dart" src="a.dart"></script>', |
| 25 }, { | 35 }, { |
| 26 'a|test.html': | 36 'a|web/test.html': |
| 27 '<!DOCTYPE html><html><head></head><body>' | 37 '<!DOCTYPE html><html><head></head><body>' |
| 28 '<script type="application/dart" ' | 38 '<script type="application/dart" ' |
| 29 'src="test.html_bootstrap.dart"></script>' | 39 'src="test.html_bootstrap.dart"></script>' |
| 30 '<script src="packages/browser/dart.js"></script>' | 40 '<script src="packages/browser/dart.js"></script>' |
| 31 '</body></html>', | 41 '</body></html>', |
| 32 | 42 |
| 33 'a|test.html_bootstrap.dart': | 43 'a|web/test.html_bootstrap.dart': |
| 34 '''library app_bootstrap; | 44 '''library app_bootstrap; |
| 35 | 45 |
| 36 import 'package:polymer/polymer.dart'; | 46 import 'package:polymer/polymer.dart'; |
| 37 import 'dart:mirrors' show currentMirrorSystem; | 47 import 'dart:mirrors' show currentMirrorSystem; |
| 38 | 48 |
| 39 import 'a.dart' as i0; | 49 import 'a.dart' as i0; |
| 40 | 50 |
| 41 void main() { | 51 void main() { |
| 42 initPolymer([ | 52 initPolymer([ |
| 43 'a.dart', | 53 'a.dart', |
| 44 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); | 54 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); |
| 45 } | 55 } |
| 46 '''.replaceAll('\n ', '\n'), | 56 '''.replaceAll('\n ', '\n'), |
| 47 }); | 57 }); |
| 48 | 58 |
| 49 testPhases('several scripts', [[new ScriptCompactor()]], { | 59 testPhases('several scripts', [[new ScriptCompactor()]], { |
| 50 'a|test.html': | 60 'a|web/test.html': |
| 51 '<!DOCTYPE html><html><head>' | 61 '<!DOCTYPE html><html><head>' |
| 52 '<script type="application/dart" src="a.dart"></script>' | 62 '<script type="application/dart" src="a.dart"></script>' |
| 53 '<script type="application/dart" src="b.dart"></script>' | 63 '<script type="application/dart" src="b.dart"></script>' |
| 54 '</head><body><div>' | 64 '</head><body><div>' |
| 55 '<script type="application/dart" src="c.dart"></script>' | 65 '<script type="application/dart" src="c.dart"></script>' |
| 56 '</div>' | 66 '</div>' |
| 57 '<script type="application/dart" src="d.dart"></script>', | 67 '<script type="application/dart" src="d.dart"></script>', |
| 58 }, { | 68 }, { |
| 59 'a|test.html': | 69 'a|web/test.html': |
| 60 '<!DOCTYPE html><html><head></head><body><div></div>' | 70 '<!DOCTYPE html><html><head></head><body><div></div>' |
| 61 '<script type="application/dart" ' | 71 '<script type="application/dart" ' |
| 62 'src="test.html_bootstrap.dart"></script>' | 72 'src="test.html_bootstrap.dart"></script>' |
| 63 '<script src="packages/browser/dart.js"></script>' | 73 '<script src="packages/browser/dart.js"></script>' |
| 64 '</body></html>', | 74 '</body></html>', |
| 65 | 75 |
| 66 'a|test.html_bootstrap.dart': | 76 'a|web/test.html_bootstrap.dart': |
| 67 '''library app_bootstrap; | 77 '''library app_bootstrap; |
| 68 | 78 |
| 69 import 'package:polymer/polymer.dart'; | 79 import 'package:polymer/polymer.dart'; |
| 70 import 'dart:mirrors' show currentMirrorSystem; | 80 import 'dart:mirrors' show currentMirrorSystem; |
| 71 | 81 |
| 72 import 'a.dart' as i0; | 82 import 'a.dart' as i0; |
| 73 import 'b.dart' as i1; | 83 import 'b.dart' as i1; |
| 74 import 'c.dart' as i2; | 84 import 'c.dart' as i2; |
| 75 import 'd.dart' as i3; | 85 import 'd.dart' as i3; |
| 76 | 86 |
| 77 void main() { | 87 void main() { |
| 78 initPolymer([ | 88 initPolymer([ |
| 79 'a.dart', | 89 'a.dart', |
| 80 'b.dart', | 90 'b.dart', |
| 81 'c.dart', | 91 'c.dart', |
| 82 'd.dart', | 92 'd.dart', |
| 83 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); | 93 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); |
| 84 } | 94 } |
| 85 '''.replaceAll('\n ', '\n'), | 95 '''.replaceAll('\n ', '\n'), |
| 86 }); | 96 }); |
| 87 } | 97 } |
| OLD | NEW |