fix(bootstrap): fix expressions containing bootstrap (fixes #3309)
This commit is contained in:
@@ -10,6 +10,7 @@ import 'reflection_remover_files/expected/index.dart' as expected;
|
||||
import 'debug_mirrors_files/expected/index.dart' as debug_mirrors;
|
||||
import 'log_mirrors_files/expected/index.dart' as log_mirrors;
|
||||
import 'verbose_files/expected/index.dart' as verbose_mirrors;
|
||||
import 'bootstrap_files/expected/index.dart' as bootstrap_expected;
|
||||
import '../common/read_file.dart';
|
||||
|
||||
main() => allTests();
|
||||
@@ -17,6 +18,7 @@ main() => allTests();
|
||||
void allTests() {
|
||||
var codegen = new Codegen('web/index.dart', ['web/index.ng_deps.dart']);
|
||||
var code = readFile('reflection_remover/index.dart').replaceAll('\r\n', '\n');
|
||||
var bootstrapCode = readFile('reflection_remover/bootstrap_files/index.dart').replaceAll('\r\n', '\n');
|
||||
|
||||
it('should remove uses of mirrors & '
|
||||
'insert calls to generated code by default.', () {
|
||||
@@ -45,4 +47,10 @@ void allTests() {
|
||||
.rewrite(parseCompilationUnit(code));
|
||||
expect(output).toEqual(log_mirrors.code);
|
||||
});
|
||||
|
||||
it('should rewrite bootstrap.', () {
|
||||
var output = new Rewriter(bootstrapCode, codegen, writeStaticInit: true)
|
||||
.rewrite(parseCompilationUnit(bootstrapCode));
|
||||
expect(output).toEqual(bootstrap_expected.code);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Tests that the reflection removal step:
|
||||
1. Comments out reflective `bootstrap.dart` import
|
||||
1. Adds `bootstrap_static.dart` import
|
||||
1. Adds the call to `initReflector`
|
||||
1. Handles bootstrap return values properly
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
library angular2.test.transform.reflection_remover.reflection_remover_files;
|
||||
|
||||
// This file is intentionally formatted as a string to avoid having the
|
||||
// automatic transformer prettify it.
|
||||
//
|
||||
// This file represents transformed user code. Because this code will be
|
||||
// linked to output by a source map, we cannot change line numbers from the
|
||||
// original code and we therefore add our generated code on the same line as
|
||||
// those we are removing.
|
||||
|
||||
var code = """
|
||||
library web_foo;
|
||||
|
||||
import 'package:angular2/bootstrap_static.dart';import 'index.ng_deps.dart' as ngStaticInit0;
|
||||
|
||||
void main() async {
|
||||
var appRef = await bootstrapStatic(MyComponent, null, () { ngStaticInit0.initReflector(); });
|
||||
}
|
||||
""";
|
||||
@@ -0,0 +1,7 @@
|
||||
library web_foo;
|
||||
|
||||
import 'package:angular2/bootstrap.dart';
|
||||
|
||||
void main() async {
|
||||
var appRef = await bootstrap(MyComponent);
|
||||
}
|
||||
Reference in New Issue
Block a user