| 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/common.dart'; |
| 7 import 'package:polymer/src/transform/script_compactor.dart'; | 8 import 'package:polymer/src/transform/script_compactor.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 ScriptCompactor(new TransformOptions())]]; |
| 14 | 16 |
| 15 testPhases('no changes', [[new ScriptCompactor()]], { | 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('no changes outside web/', [[new ScriptCompactor()]], { | 23 testPhases('no changes outside web/', phases, { |
| 22 'a|lib/test.html': | 24 'a|lib/test.html': |
| 23 '<!DOCTYPE html><html><head>' | 25 '<!DOCTYPE html><html><head>' |
| 24 '<script type="application/dart" src="a.dart"></script>', | 26 '<script type="application/dart" src="a.dart"></script>', |
| 25 }, { | 27 }, { |
| 26 'a|lib/test.html': | 28 'a|lib/test.html': |
| 27 '<!DOCTYPE html><html><head>' | 29 '<!DOCTYPE html><html><head>' |
| 28 '<script type="application/dart" src="a.dart"></script>', | 30 '<script type="application/dart" src="a.dart"></script>', |
| 29 }); | 31 }); |
| 30 | 32 |
| 31 testPhases('single script', [[new ScriptCompactor()]], { | 33 testPhases('single script', phases, { |
| 32 'a|web/test.html': | 34 'a|web/test.html': |
| 33 '<!DOCTYPE html><html><head>' | 35 '<!DOCTYPE html><html><head>' |
| 34 '<script type="application/dart" src="a.dart"></script>', | 36 '<script type="application/dart" src="a.dart"></script>', |
| 35 }, { | 37 }, { |
| 36 'a|web/test.html': | 38 'a|web/test.html': |
| 37 '<!DOCTYPE html><html><head></head><body>' | 39 '<!DOCTYPE html><html><head></head><body>' |
| 38 '<script type="application/dart" ' | 40 '<script type="application/dart" ' |
| 39 'src="test.html_bootstrap.dart"></script>' | 41 'src="test.html_bootstrap.dart"></script>' |
| 40 '<script src="packages/browser/dart.js"></script>' | 42 '<script src="packages/browser/dart.js"></script>' |
| 41 '</body></html>', | 43 '</body></html>', |
| 42 | 44 |
| 43 'a|web/test.html_bootstrap.dart': | 45 'a|web/test.html_bootstrap.dart': |
| 44 '''library app_bootstrap; | 46 '''library app_bootstrap; |
| 45 | 47 |
| 46 import 'package:polymer/polymer.dart'; | 48 import 'package:polymer/polymer.dart'; |
| 47 import 'dart:mirrors' show currentMirrorSystem; | 49 import 'dart:mirrors' show currentMirrorSystem; |
| 48 | 50 |
| 49 import 'a.dart' as i0; | 51 import 'a.dart' as i0; |
| 50 | 52 |
| 51 void main() { | 53 void main() { |
| 52 initPolymer([ | 54 initPolymer([ |
| 53 'a.dart', | 55 'a.dart', |
| 54 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); | 56 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); |
| 55 } | 57 } |
| 56 '''.replaceAll('\n ', '\n'), | 58 '''.replaceAll('\n ', '\n'), |
| 57 }); | 59 }); |
| 58 | 60 |
| 59 testPhases('several scripts', [[new ScriptCompactor()]], { | 61 testPhases('several scripts', phases, { |
| 60 'a|web/test.html': | 62 'a|web/test.html': |
| 61 '<!DOCTYPE html><html><head>' | 63 '<!DOCTYPE html><html><head>' |
| 62 '<script type="application/dart" src="a.dart"></script>' | 64 '<script type="application/dart" src="a.dart"></script>' |
| 63 '<script type="application/dart" src="b.dart"></script>' | 65 '<script type="application/dart" src="b.dart"></script>' |
| 64 '</head><body><div>' | 66 '</head><body><div>' |
| 65 '<script type="application/dart" src="c.dart"></script>' | 67 '<script type="application/dart" src="c.dart"></script>' |
| 66 '</div>' | 68 '</div>' |
| 67 '<script type="application/dart" src="d.dart"></script>', | 69 '<script type="application/dart" src="d.dart"></script>', |
| 68 }, { | 70 }, { |
| 69 'a|web/test.html': | 71 'a|web/test.html': |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 initPolymer([ | 90 initPolymer([ |
| 89 'a.dart', | 91 'a.dart', |
| 90 'b.dart', | 92 'b.dart', |
| 91 'c.dart', | 93 'c.dart', |
| 92 'd.dart', | 94 'd.dart', |
| 93 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); | 95 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); |
| 94 } | 96 } |
| 95 '''.replaceAll('\n ', '\n'), | 97 '''.replaceAll('\n ', '\n'), |
| 96 }); | 98 }); |
| 97 } | 99 } |
| OLD | NEW |