Chromium Code Reviews| 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(' ', '') |
| + }, []); |
| +} |