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

Unified Diff: test/plugin_transformer_test.dart

Issue 888943002: added plugin transformer which initializers can extend to do additional post-processing during tran… (Closed) Base URL: git@github.com:dart-lang/static-init.git@master
Patch Set: make allAssets public Created 5 years, 11 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
« lib/plugin_transformer.dart ('K') | « test/initializer_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/plugin_transformer_test.dart
diff --git a/test/plugin_transformer_test.dart b/test/plugin_transformer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d04dd635147ec9233ed0d993eb5102ec1a2d65a9
--- /dev/null
+++ b/test/plugin_transformer_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2015, 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 initialize.plugin_transformer_test;
+
+import 'common.dart';
Jennifer Messerly 2015/01/30 20:34:26 trivial: put this after package: imports?
jakemac 2015/01/30 22:16:18 Done.
+import 'package:analyzer/analyzer.dart';
+import 'package:initialize/plugin_transformer.dart';
+import 'package:source_maps/refactor.dart';
+import 'package:unittest/compact_vm_config.dart';
+
+// Simple plugin which just removes all initMethod initializers.
+class DeleteInitMethodPlugin extends InitializePluginTransformer {
+ DeleteInitMethodPlugin(String bootstrap) : super(bootstrap);
+
+ initEntry(
+ InstanceCreationExpression expression, TextEditTransaction transaction) {
+ var firstArg = expression.argumentList.arguments[0];
+ if (firstArg is PrefixedIdentifier &&
+ firstArg.identifier.toString() == 'initMethod') {
+ removeInitializer(expression, transaction);
+ }
+ }
+}
+
+main() {
+ useCompactVMConfiguration();
+
+ var transformer = new DeleteInitMethodPlugin('web/index.bootstrap.dart');
+
+ testPhases('basic', [[transformer]], {
+ 'a|web/index.bootstrap.dart': '''
+ import 'package:initialize/src/static_loader.dart';
+ import 'package:initialize/initialize.dart';
+ import 'index.dart' as i0;
+
+ main() {
+ initializers.addAll([
+ new InitEntry(i0.initMethod, const LibraryIdentifier(#a, null, 'a.dart')),
Jennifer Messerly 2015/01/30 20:34:26 long line
jakemac 2015/01/30 22:16:18 This is actually intentional in this case, for sim
Jennifer Messerly 2015/01/30 23:11:03 right, but this is a string literal in the a human
+ new InitEntry(i0.initMethod, const LibraryIdentifier(#a, 'a', 'a.dart')),
+ new InitEntry(i0.initMethod, i0.a),
+ new InitEntry(const i0.DynamicInit('a()'), i0.a),
+ ]);
+
+ i0.main();
+ }
+ '''.replaceAll(' ', '')
+ }, {
+ 'a|web/index.bootstrap.dart': '''
+ import 'package:initialize/src/static_loader.dart';
+ import 'package:initialize/initialize.dart';
+ import 'index.dart' as i0;
+
+ main() {
+ initializers.addAll([
+ new InitEntry(const i0.DynamicInit('a()'), i0.a),
+ ]);
+
+ i0.main();
+ }
+ '''.replaceAll(' ', '')
+ }, []);
+}
« lib/plugin_transformer.dart ('K') | « test/initializer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698