Chromium Code Reviews| Index: test/transform/script_compactor_test.dart |
| diff --git a/test/transform/script_compactor_test.dart b/test/transform/script_compactor_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6ded6c2452a29f2db915d4d75dbb075d60ee06c5 |
| --- /dev/null |
| +++ b/test/transform/script_compactor_test.dart |
| @@ -0,0 +1,83 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library polymer.test.transform.script_compactor_test; |
| + |
| +import 'package:polymer/src/transform/script_compactor.dart'; |
| +import 'package:unittest/compact_vm_config.dart'; |
| + |
| +import 'common.dart'; |
| + |
| +void main() { |
| + useCompactVMConfiguration(); |
| + |
| + testPhases('no changes', [[new ScriptCompactor()]], { |
| + 'a|test.html': '<!DOCTYPE html><html></html>', |
| + }, { |
| + 'a|test.html': '<!DOCTYPE html><html></html>', |
| + }); |
| + |
| + testPhases('single script', [[new ScriptCompactor()]], { |
| + 'a|test.html': |
| + '<!DOCTYPE html><html><head>' |
| + '<script type="application/dart" src="a.dart"></script>', |
| + }, { |
| + 'a|test.html': |
| + '<!DOCTYPE html><html><head></head><body>' |
| + '<script type="application/dart" ' |
| + 'src="test.html_bootstrap.dart"></script>' |
| + '</body></html>', |
| + |
| + 'a|test.html_bootstrap.dart': |
| + 'library app_bootstrap;\n\n' |
|
Jennifer Messerly
2013/08/19 22:57:26
this would be a good use case for triple quote :)
Siggi Cherem (dart-lang)
2013/08/21 20:35:42
Done.
|
| + "import 'package:polymer/polymer.dart';\n" |
| + "import 'dart:mirrors' show currentMirrorSystem;\n\n" |
| + "import 'a.dart' as i0;\n\n" |
| + 'void main() {\n' |
| + ' initPolymer([\n' |
| + " 'a.dart',\n" |
| + ' ],\n' |
| + ' currentMirrorSystem().findLibrary(const Symbol(' |
| + "'app_bootstrap'))\n" |
| + ' .first.uri.toString());\n' |
| + '}\n', |
| + }); |
| + |
| + testPhases('several scripts', [[new ScriptCompactor()]], { |
| + 'a|test.html': |
| + '<!DOCTYPE html><html><head>' |
| + '<script type="application/dart" src="a.dart"></script>' |
| + '<script type="application/dart" src="b.dart"></script>' |
| + '</head><body><div>' |
| + '<script type="application/dart" src="c.dart"></script>' |
| + '</div>' |
| + '<script type="application/dart" src="d.dart"></script>', |
| + }, { |
| + 'a|test.html': |
| + '<!DOCTYPE html><html><head></head><body><div></div>' |
| + '<script type="application/dart" ' |
| + 'src="test.html_bootstrap.dart"></script>' |
| + '</body></html>', |
| + |
| + 'a|test.html_bootstrap.dart': |
| + 'library app_bootstrap;\n\n' |
| + "import 'package:polymer/polymer.dart';\n" |
| + "import 'dart:mirrors' show currentMirrorSystem;\n\n" |
| + "import 'a.dart' as i0;\n" |
| + "import 'b.dart' as i1;\n" |
| + "import 'c.dart' as i2;\n" |
| + "import 'd.dart' as i3;\n\n" |
| + 'void main() {\n' |
| + ' initPolymer([\n' |
| + " 'a.dart',\n" |
| + " 'b.dart',\n" |
| + " 'c.dart',\n" |
| + " 'd.dart',\n" |
| + ' ],\n' |
| + ' currentMirrorSystem().findLibrary(const Symbol(' |
| + "'app_bootstrap'))\n" |
| + ' .first.uri.toString());\n' |
| + '}\n', |
| + }); |
| +} |