2015-03-06 14:10:14 -05:00
|
|
|
library angular2.test.transform.reflection_remover;
|
|
|
|
|
|
|
|
import 'package:analyzer/analyzer.dart';
|
2015-04-17 14:12:35 -04:00
|
|
|
import 'package:angular2/src/transform/common/mirror_mode.dart';
|
2015-03-06 14:10:14 -05:00
|
|
|
import 'package:angular2/src/transform/reflection_remover/codegen.dart';
|
|
|
|
import 'package:angular2/src/transform/reflection_remover/rewriter.dart';
|
2015-03-20 18:25:29 -04:00
|
|
|
import 'package:guinness/guinness.dart';
|
2015-03-06 14:10:14 -05:00
|
|
|
|
|
|
|
import 'reflection_remover_files/expected/index.dart' as expected;
|
2015-04-17 14:12:35 -04:00
|
|
|
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;
|
2015-03-06 14:10:14 -05:00
|
|
|
import '../common/read_file.dart';
|
|
|
|
|
|
|
|
void allTests() {
|
2015-04-09 20:49:11 -04:00
|
|
|
var codegen = new Codegen('web/index.dart', ['web/index.ng_deps.dart']);
|
2015-06-25 12:29:19 -04:00
|
|
|
var code = readFile('reflection_remover/index.dart').replaceAll('\r\n', '\n');
|
2015-03-06 14:10:14 -05:00
|
|
|
|
2015-04-17 14:12:35 -04:00
|
|
|
it('should remove uses of mirrors & '
|
|
|
|
'insert calls to generated code by default.', () {
|
2015-03-06 14:10:14 -05:00
|
|
|
var output =
|
|
|
|
new Rewriter(code, codegen).rewrite(parseCompilationUnit(code));
|
2015-03-20 18:25:29 -04:00
|
|
|
expect(output).toEqual(expected.code);
|
2015-03-06 14:10:14 -05:00
|
|
|
});
|
2015-04-17 14:12:35 -04:00
|
|
|
|
|
|
|
it('should replace uses of mirrors with the debug implementation & '
|
|
|
|
'insert calls to generated code in `MirrorMode.debug`.', () {
|
|
|
|
var output = new Rewriter(code, codegen, mirrorMode: MirrorMode.debug)
|
|
|
|
.rewrite(parseCompilationUnit(code));
|
|
|
|
expect(output).toEqual(debug_mirrors.code);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should replace uses of mirrors with the verbose implementation '
|
|
|
|
'in `MirrorMode.verbose`.', () {
|
|
|
|
var output = new Rewriter(code, codegen, mirrorMode: MirrorMode.verbose)
|
|
|
|
.rewrite(parseCompilationUnit(code));
|
|
|
|
expect(output).toEqual(verbose_mirrors.code);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not initialize the reflector when `writeStaticInit` is `false`.',
|
|
|
|
() {
|
|
|
|
var output = new Rewriter(code, codegen, writeStaticInit: false)
|
|
|
|
.rewrite(parseCompilationUnit(code));
|
|
|
|
expect(output).toEqual(log_mirrors.code);
|
|
|
|
});
|
2015-03-06 14:10:14 -05:00
|
|
|
}
|