Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Unified Diff: pkg/polymer/test/build/code_extractor.dart

Issue 180933002: combine script extractor and import inliner (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: refactor Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/polymer/test/build/code_extractor.dart
diff --git a/pkg/polymer/test/build/code_extractor_test.dart b/pkg/polymer/test/build/code_extractor.dart
similarity index 58%
rename from pkg/polymer/test/build/code_extractor_test.dart
rename to pkg/polymer/test/build/code_extractor.dart
index 3130faf424b0ba9d97bf11fbb9b84827571c53b8..b4ea6d1f6c4c09c25b31b2c10aec5d5dcff5ad7e 100644
--- a/pkg/polymer/test/build/code_extractor_test.dart
+++ b/pkg/polymer/test/build/code_extractor.dart
@@ -2,18 +2,11 @@
// 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.build.code_extractor_test;
-
-import 'package:polymer/src/build/code_extractor.dart';
-import 'package:polymer/src/build/common.dart';
-import 'package:unittest/compact_vm_config.dart';
-
-import 'common.dart';
-
-void main() {
- useCompactVMConfiguration();
- var phases = [[new InlineCodeExtractor(new TransformOptions())]];
+// TODO(jmesserly): merge into import_inliner_test.dart.
+// Keeping here for now so it's easier to see the diff.
Siggi Cherem (dart-lang) 2014/02/26 22:27:09 nice, thank you :)
+part of polymer.test.build.import_inliner_test;
+void codeExtractorTests() {
testPhases('no changes', phases, {
'a|web/test.html': '<!DOCTYPE html><html></html>',
}, {
@@ -26,9 +19,9 @@ void main() {
'<script type="application/dart">main() { }</script>',
}, {
'a|web/test.html':
- '<!DOCTYPE html><html><head>'
+ '<!DOCTYPE html><html><head></head><body>'
'<script type="application/dart" src="test.html.0.dart"></script>'
- '</head><body></body></html>',
+ '</body></html>',
'a|web/test.html.0.dart':
'library web_test_html_0;\nmain() { }',
@@ -40,45 +33,37 @@ void main() {
'<script type="application/dart">library f;\nmain() { }</script>',
}, {
'a|web/test.html':
- '<!DOCTYPE html><html><head>'
+ '<!DOCTYPE html><html><head></head><body>'
'<script type="application/dart" src="test.html.0.dart"></script>'
- '</head><body></body></html>',
+ '</body></html>',
'a|web/test.html.0.dart':
'library f;\nmain() { }',
});
- testPhases('under lib/ directory also transformed', phases, {
+ testPhases('under lib/ directory not transformed', phases, {
'a|lib/test.html':
'<!DOCTYPE html><html><head>'
'<script type="application/dart">library f;\nmain() { }</script>',
}, {
'a|lib/test.html':
'<!DOCTYPE html><html><head>'
- '<script type="application/dart" src="test.html.0.dart"></script>'
- '</head><body></body></html>',
-
- 'a|lib/test.html.0.dart':
- 'library f;\nmain() { }',
+ '<script type="application/dart">library f;\nmain() { }</script>'
});
- testPhases('multiple scripts', phases, {
+ testPhases('multiple scripts - only emit first', phases, {
'a|web/test.html':
'<!DOCTYPE html><html><head>'
'<script type="application/dart">library a1;\nmain1() { }</script>'
'<script type="application/dart">library a2;\nmain2() { }</script>',
}, {
'a|web/test.html':
- '<!DOCTYPE html><html><head>'
+ '<!DOCTYPE html><html><head></head><body>'
'<script type="application/dart" src="test.html.0.dart"></script>'
- '<script type="application/dart" src="test.html.1.dart"></script>'
- '</head><body></body></html>',
+ '</body></html>',
'a|web/test.html.0.dart':
'library a1;\nmain1() { }',
-
- 'a|web/test.html.1.dart':
- 'library a2;\nmain2() { }',
});
testPhases('multiple deeper scripts', phases, {
@@ -93,20 +78,46 @@ void main() {
}, {
'a|web/test.html':
'<!DOCTYPE html><html><head>'
+ '</head><body>'
'<script type="application/dart" src="test.html.0.dart"></script>'
- '</head><body><div>'
- '<script type="application/dart" src="test.html.1.dart"></script>'
- '</div><div><div>'
- '<script type="application/dart" src="test.html.2.dart"></script>'
+ '<div></div><div><div>'
'</div></div></body></html>',
'a|web/test.html.0.dart':
'library web_test_html_0;\nmain1() { }',
+ });
- 'a|web/test.html.1.dart':
- 'library web_test_html_1;\nmain2() { }',
-
- 'a|web/test.html.2.dart':
- 'library web_test_html_2;\nmain3() { }',
+ testPhases('fixes import/export/part URIs', phases, {
Siggi Cherem (dart-lang) 2014/02/26 22:27:09 Could we add a similar test that includes files in
Jennifer Messerly 2014/02/27 22:31:40 GOOOOOOD catch! Cross pkg URLs were totally broken
+ 'a|web/test.html':
+ '<!DOCTYPE html><html><head>'
+ '<link rel="import" href="test2/foo.html">'
+ '</head><body></body></html>',
+ 'a|web/test2/foo.html':
+ '<!DOCTYPE html><html><head></head><body>'
+ '<script type="application/dart">'
+ "import 'foo.dart';"
+ "export 'bar.dart';"
+ "part 'baz.dart';"
+ '</script>'
+ '</body></html>',
+ }, {
+ 'a|web/test.html':
+ '<!DOCTYPE html><html><head></head><body></body></html>',
+ 'a|web/test.html.scriptUrls': '[["a","web/test.html.0.dart"]]',
+ 'a|web/test.html.0.dart':
+ "library web_test_html_0;\n"
+ "import 'test2/foo.dart';"
+ "export 'test2/bar.dart';"
+ "part 'test2/baz.dart';",
+ 'a|web/test2/foo.html':
+ '<!DOCTYPE html><html><head></head><body>'
+ '<script type="application/dart" src="foo.html.0.dart"></script>'
+ '</body></html>',
+ 'a|web/test2/foo.html.scriptUrls': '[]',
+ 'a|web/test2/foo.html.0.dart':
+ "library web_test2_foo_html_0;\n"
+ "import 'foo.dart';"
+ "export 'bar.dart';"
+ "part 'baz.dart';",
});
}

Powered by Google App Engine
This is Rietveld 408576698