From 267121ee1783ace4d662db112eed1f00ff62d277 Mon Sep 17 00:00:00 2001 From: Tim Blasi Date: Tue, 15 Sep 2015 10:27:54 -0700 Subject: [PATCH] refactor(dart/transform): Test directive processor using protos Directly test the `NgDepsModel` object created by the `DirectiveProcessor` rather than string comparing output Dart code. --- .../lib/src/transform/common/logging.dart | 2 +- .../directive_processor/rewriter.dart | 8 +- .../directive_processor/transformer.dart | 10 +- .../transform/directive_linker/all_tests.dart | 3 + .../expected/hello.ng_deps.dart | 25 - .../directive_processor/all_tests.dart | 495 ++++++++++++------ .../expected/package_soup.ng_deps.dart | 17 - .../expected/relative_soup.ng_deps.dart | 17 - .../expected/hello.aliases.json | 15 - .../expected/hello.ng_deps.dart | 25 - .../expected/hello.ng_deps.dart | 26 - .../expected/soup.ng_deps.dart | 20 - .../expected/soup.ng_deps.dart | 99 ---- .../expected/soup.ng_deps.dart | 21 - .../expected/hello.ng_deps.dart | 23 - .../expected/soup.ng_deps.dart | 21 - .../expected/main.ng_deps.dart | 25 - .../expected/hello.ng_deps.dart | 23 - .../expected/hello.ng_deps.dart | 23 - .../expected/soup.ng_deps.dart | 21 - .../part_files/expected/main.ng_deps.dart | 21 - .../expected/soup.ng_deps.dart | 21 - .../expected/hello.ng_deps.dart | 21 - .../expected/hello.ng_deps.dart | 24 - .../expected/soup.ng_deps.dart | 17 - .../expected/soup.ng_deps.dart | 18 - .../expected/hello.ng_deps.dart | 21 - 27 files changed, 347 insertions(+), 715 deletions(-) delete mode 100644 modules_dart/transform/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/package_soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/relative_soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.aliases.json delete mode 100644 modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/interface_chain_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/interface_lifecycle_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/interfaces_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/multiple_interface_lifecycle_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/multiple_part_files/expected/main.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/parameter_metadata/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/part_files/expected/main.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/prefixed_interface_lifecycle_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/static_function_files/expected/hello.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/superclass_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/superclass_lifecycle_files/expected/soup.ng_deps.dart delete mode 100644 modules_dart/transform/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart diff --git a/modules_dart/transform/lib/src/transform/common/logging.dart b/modules_dart/transform/lib/src/transform/common/logging.dart index 9ad1e9aa32..8dea306da7 100644 --- a/modules_dart/transform/lib/src/transform/common/logging.dart +++ b/modules_dart/transform/lib/src/transform/common/logging.dart @@ -19,7 +19,7 @@ Future initZoned(Transform t, _SimpleCallback fn) => Future setZoned(BuildLogger logger, _SimpleCallback fn) async { return runZoned(() async { try { - await fn(); + return await fn(); } on AnalyzerError catch (e) { // Do not worry about printing the stack trace, barback will handle that // on its own when it catches the rethrown exception. diff --git a/modules_dart/transform/lib/src/transform/directive_processor/rewriter.dart b/modules_dart/transform/lib/src/transform/directive_processor/rewriter.dart index 7ae4a0af15..9d77a88d0a 100644 --- a/modules_dart/transform/lib/src/transform/directive_processor/rewriter.dart +++ b/modules_dart/transform/lib/src/transform/directive_processor/rewriter.dart @@ -8,6 +8,7 @@ import 'package:angular2/src/transform/common/asset_reader.dart'; import 'package:angular2/src/transform/common/async_string_writer.dart'; import 'package:angular2/src/transform/common/code/ng_deps_code.dart'; import 'package:angular2/src/transform/common/logging.dart'; +import 'package:angular2/src/transform/common/model/ng_deps_model.pb.dart'; import 'package:angular2/src/transform/common/xhr_impl.dart'; import 'package:angular2/src/transform/common/ng_meta.dart'; import 'package:barback/barback.dart' show AssetId; @@ -24,7 +25,7 @@ import 'inliner.dart'; /// If no Angular 2 `Directive`s are found in `code`, returns the empty /// string unless `forceGenerate` is true, in which case an empty ngDeps /// file is created. -Future createNgDeps(AssetReader reader, AssetId assetId, +Future createNgDeps(AssetReader reader, AssetId assetId, AnnotationMatcher annotationMatcher, NgMeta ngMeta, {bool inlineViews}) async { // TODO(kegluneq): Shortcut if we can determine that there are no @@ -64,10 +65,7 @@ Future createNgDeps(AssetReader reader, AssetId assetId, await inlineViewProps(new XhrImpl(reader, assetId), ngDepsModel); } - var buffer = new StringBuffer(); - var ngDepsWriter = new NgDepsWriter(buffer); - ngDepsWriter.writeNgDepsModel(ngDepsModel); - return '$buffer'; + return ngDepsModel; } /// Processes `visitor.parts`, reading and appending their contents to the diff --git a/modules_dart/transform/lib/src/transform/directive_processor/transformer.dart b/modules_dart/transform/lib/src/transform/directive_processor/transformer.dart index 865433b886..5e1ef83d98 100644 --- a/modules_dart/transform/lib/src/transform/directive_processor/transformer.dart +++ b/modules_dart/transform/lib/src/transform/directive_processor/transformer.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:angular2/src/transform/common/asset_reader.dart'; +import 'package:angular2/src/transform/common/code/ng_deps_code.dart'; import 'package:angular2/src/transform/common/logging.dart' as log; import 'package:angular2/src/transform/common/names.dart'; import 'package:angular2/src/transform/common/options.dart'; @@ -35,17 +36,20 @@ class DirectiveProcessor extends Transformer { var asset = transform.primaryInput; var reader = new AssetReader.fromTransform(transform); var ngMeta = new NgMeta.empty(); - var ngDepsSrc = await createNgDeps( + var ngDepsModel = await createNgDeps( reader, asset.id, options.annotationMatcher, ngMeta, inlineViews: options.inlineViews); - if (ngDepsSrc != null && ngDepsSrc.isNotEmpty) { + if (ngDepsModel != null) { var ngDepsAssetId = transform.primaryInput.id.changeExtension(DEPS_EXTENSION); if (await transform.hasInput(ngDepsAssetId)) { log.logger.error('Clobbering ${ngDepsAssetId}. ' 'This probably will not end well'); } - transform.addOutput(new Asset.fromString(ngDepsAssetId, ngDepsSrc)); + var buf = new StringBuffer(); + var writer = new NgDepsWriter(buf); + writer.writeNgDepsModel(ngDepsModel); + transform.addOutput(new Asset.fromString(ngDepsAssetId, '$buf')); } if (!ngMeta.isEmpty) { var ngAliasesId = diff --git a/modules_dart/transform/test/transform/directive_linker/all_tests.dart b/modules_dart/transform/test/transform/directive_linker/all_tests.dart index 378ef55ba2..14d6252356 100644 --- a/modules_dart/transform/test/transform/directive_linker/all_tests.dart +++ b/modules_dart/transform/test/transform/directive_linker/all_tests.dart @@ -1,6 +1,9 @@ library angular2.test.transform.directive_linker.all_tests; import 'package:barback/barback.dart'; +import 'package:angular2/src/transform/common/model/annotation_model.pb.dart'; +import 'package:angular2/src/transform/common/model/import_export_model.pb.dart'; +import 'package:angular2/src/transform/common/model/ng_deps_model.pb.dart'; import 'package:angular2/src/transform/directive_linker/linker.dart'; import 'package:dart_style/dart_style.dart'; import 'package:guinness/guinness.dart'; diff --git a/modules_dart/transform/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart deleted file mode 100644 index 7b8240b498..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,25 +0,0 @@ -library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - styles: const [r'''.greeting { .color: blue; }''',], - template: r'''{{greeting}}''', - templateUrl: 'package:other_package/template.html') - ], const [], () => new HelloCmp())) - ..registerFunction( - hello, new _ngRef.ReflectionInfo(const [const Injectable()], const [])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/all_tests.dart b/modules_dart/transform/test/transform/directive_processor/all_tests.dart index 9b27186a0b..812c8ec64f 100644 --- a/modules_dart/transform/test/transform/directive_processor/all_tests.dart +++ b/modules_dart/transform/test/transform/directive_processor/all_tests.dart @@ -1,5 +1,6 @@ library angular2.test.transform.directive_processor.all_tests; +import 'dart:async'; import 'dart:convert'; import 'package:barback/barback.dart'; @@ -7,6 +8,8 @@ import 'package:angular2/src/transform/directive_processor/rewriter.dart'; import 'package:angular2/src/transform/common/annotation_matcher.dart'; import 'package:angular2/src/transform/common/asset_reader.dart'; import 'package:angular2/src/transform/common/logging.dart' as log; +import 'package:angular2/src/transform/common/model/reflection_info_model.pb.dart'; +import 'package:angular2/src/transform/common/model/ng_deps_model.pb.dart'; import 'package:angular2/src/transform/common/ng_meta.dart'; import 'package:code_transformers/messages/build_logger.dart'; import 'package:dart_style/dart_style.dart'; @@ -21,174 +24,342 @@ main() { allTests(); } -void allTests() { - _testProcessor('should preserve parameter annotations as const instances.', - 'parameter_metadata/soup.dart'); - - _testProcessor('should handle `part` directives.', 'part_files/main.dart'); - - _testProcessor('should handle multiple `part` directives.', - 'multiple_part_files/main.dart'); - - _testProcessor('should not generate .ng_deps.dart for `part` files.', - 'part_files/part.dart'); - - _testProcessor('should recognize custom annotations with package: imports', - 'custom_metadata/package_soup.dart', - customDescriptors: [ - const ClassDescriptor('Soup', 'package:soup/soup.dart', - superClass: 'Component'), - ]); - - _testProcessor('should recognize custom annotations with relative imports', - 'custom_metadata/relative_soup.dart', - assetId: new AssetId('soup', 'lib/relative_soup.dart'), - customDescriptors: [ - const ClassDescriptor('Soup', 'package:soup/annotations/soup.dart', - superClass: 'Component'), - ]); - - _testProcessor( - 'Requires the specified import.', 'custom_metadata/bad_soup.dart', - customDescriptors: [ - const ClassDescriptor('Soup', 'package:soup/soup.dart', - superClass: 'Component'), - ]); - - _testProcessor( - 'should inline `templateUrl` values.', 'url_expression_files/hello.dart'); - - var absoluteReader = new TestAssetReader(); - absoluteReader.addAsset( - new AssetId('other_package', 'lib/template.html'), - readFile( - 'directive_processor/absolute_url_expression_files/template.html')); - absoluteReader.addAsset( - new AssetId('other_package', 'lib/template.css'), - readFile( - 'directive_processor/absolute_url_expression_files/template.css')); - _testProcessor( - 'should inline `templateUrl` and `styleUrls` values expressed' - ' as absolute urls.', - 'absolute_url_expression_files/hello.dart', - reader: absoluteReader); - - _testProcessor( - 'should inline multiple `styleUrls` values expressed as absolute urls.', - 'multiple_style_urls_files/hello.dart'); - - absoluteReader.addAsset(new AssetId('a', 'lib/template.html'), - readFile('directive_processor/multiple_style_urls_files/template.html')); - absoluteReader.addAsset(new AssetId('a', 'lib/template.css'), - readFile('directive_processor/multiple_style_urls_files/template.css')); - absoluteReader.addAsset( - new AssetId('a', 'lib/template_other.css'), - readFile( - 'directive_processor/multiple_style_urls_files/template_other.css')); - _testProcessor( - 'shouldn\'t inline multiple `styleUrls` values expressed as absolute ' - 'urls.', - 'multiple_style_urls_not_inlined_files/hello.dart', - inlineViews: false, - reader: absoluteReader); - - _testProcessor('should inline `templateUrl`s expressed as adjacent strings.', - 'split_url_expression_files/hello.dart'); - - _testProcessor('should report implemented types as `interfaces`.', - 'interfaces_files/soup.dart'); - - _testProcessor('should not include transitively implemented types.', - 'interface_chain_files/soup.dart'); - - _testProcessor('should not include superclasses in `interfaces`.', - 'superclass_files/soup.dart'); - - _testProcessor('should populate multiple `lifecycle` values when necessary.', - 'multiple_interface_lifecycle_files/soup.dart'); - - _testProcessor( - 'should populate `lifecycle` when lifecycle superclass is present.', - 'superclass_lifecycle_files/soup.dart'); - - _testProcessor('should populate `lifecycle` with prefix when necessary.', - 'prefixed_interface_lifecycle_files/soup.dart'); - - _testProcessor( - 'should not throw/hang on invalid urls', 'invalid_url_files/hello.dart', - expectedLogs: [ - 'ERROR: Uri /bad/absolute/url.html not supported from angular2|test/' - 'transform/directive_processor/invalid_url_files/hello.dart, could not ' - 'build AssetId', - 'ERROR: Could not read asset at uri package:invalid/package.css from ' - 'angular2|test/transform/directive_processor/invalid_url_files/' - 'hello.dart', - 'ERROR: Could not read asset at uri bad_relative_url.css from angular2|' - 'test/transform/directive_processor/invalid_url_files/hello.dart' - ]); - - _testProcessor('should find and register static functions.', - 'static_function_files/hello.dart'); - - _testProcessor('should find direcive aliases patterns.', - 'directive_aliases_files/hello.dart', - reader: absoluteReader); +Expect _expectSelector(ReflectionInfoModel model) { + expect(model.annotations.isNotEmpty).toBeTrue(); + var componentAnnotation = model.annotations + .firstWhere((e) => e.name == 'Component', orElse: () => null); + expect(componentAnnotation).toBeNotNull(); + var selectorArg = componentAnnotation.namedParameters + .firstWhere((e) => e.name == 'selector', orElse: () => null); + expect(selectorArg).toBeNotNull(); + return expect(selectorArg.value); } -void _testProcessor(String name, String inputPath, +void allTests() { + it('should preserve parameter annotations.', () async { + var model = await _testCreateModel('parameter_metadata/soup.dart'); + expect(model.reflectables.length).toBe(1); + var reflectable = model.reflectables.first; + expect(reflectable.parameters.length).toBe(2); + + expect(reflectable.parameters.first.typeName).toEqual('String'); + expect(reflectable.parameters.first.metadata.length).toBe(1); + expect(reflectable.parameters.first.metadata.first).toContain('Tasty'); + expect(reflectable.parameters.first.paramName).toEqual('description'); + + var typeName = reflectable.parameters[1].typeName; + expect(typeName == null || typeName.isEmpty).toBeTrue(); + var secondParam = reflectable.parameters[1]; + expect(secondParam.metadata.first).toContain('Inject(Salt)'); + expect(secondParam.paramName).toEqual('salt'); + }); + + describe('part support', () { + var modelFuture = _testCreateModel('part_files/main.dart'); + + it('should include directives from the part.', () async { + var model = await modelFuture; + expect(model.reflectables.length).toBe(2); + }); + + it('should list part contributions first.', () async { + var model = await modelFuture; + expect(model.reflectables.first.name).toEqual('PartComponent'); + _expectSelector(model.reflectables.first).toEqual("'[part]'"); + }); + + it('should list main contributions second.', () async { + var model = await modelFuture; + expect(model.reflectables[1].name).toEqual('MainComponent'); + _expectSelector(model.reflectables[1]).toEqual("'[main]'"); + }); + + it('should handle multiple `part` directives.', () async { + var model = await _testCreateModel('multiple_part_files/main.dart'); + expect(model.reflectables.length).toEqual(3); + _expectSelector(model.reflectables.first).toEqual("'[part1]'"); + _expectSelector(model.reflectables[1]).toEqual("'[part2]'"); + _expectSelector(model.reflectables[2]).toEqual("'[main]'"); + }); + + it('should not generate .ng_deps.dart for `part` files.', () async { + var model = await _testCreateModel('part_files/part.dart'); + expect(model).toBeNull(); + }); + }); + + describe('custom annotations', () { + it('should be recognized from package: imports', () async { + var model = + await _testCreateModel('custom_metadata/package_soup.dart', customDescriptors: + [ + const ClassDescriptor('Soup', 'package:soup/soup.dart', + superClass: 'Component') + ]); + expect(model.reflectables.length).toEqual(1); + expect(model.reflectables.first.name).toEqual('PackageSoup'); + }); + + it('should be recognized from relative imports', () async { + var model = await _testCreateModel('custom_metadata/relative_soup.dart', + assetId: new AssetId('soup', 'lib/relative_soup.dart'), + customDescriptors: [ + const ClassDescriptor('Soup', 'package:soup/annotations/soup.dart', + superClass: 'Component') + ]); + expect(model.reflectables.length).toEqual(1); + expect(model.reflectables.first.name).toEqual('RelativeSoup'); + }); + + it('should ignore annotations that are not imported', () async { + var model = + await _testCreateModel('custom_metadata/bad_soup.dart', customDescriptors: + [ + const ClassDescriptor('Soup', 'package:soup/soup.dart', + superClass: 'Component') + ]); + expect(model).toBeNull(); + }); + }); + + describe('inliner', () { + var absoluteReader; + beforeEach(() { + absoluteReader = new TestAssetReader(); + }); + + it('should inline `templateUrl` values', () async { + var model = await _testCreateModel('url_expression_files/hello.dart'); + expect(model.reflectables.isNotEmpty).toBeTrue(); + var view = + model.reflectables.first.annotations.firstWhere((a) => a.isView); + expect(view.namedParameters + .firstWhere((p) => p.name == 'templateUrl') + .value).toContain('template.html'); + expect(view.namedParameters.firstWhere((p) => p.name == 'template').value) + .toContain('{{greeting}}'); + }); + + it( + 'should inline `templateUrl` and `styleUrls` values expressed as ' + 'absolute urls.', () async { + absoluteReader.addAsset( + new AssetId('other_package', 'lib/template.html'), + readFile( + 'directive_processor/absolute_url_expression_files/template.html')); + absoluteReader.addAsset( + new AssetId('other_package', 'lib/template.css'), + readFile( + 'directive_processor/absolute_url_expression_files/template.css')); + var model = await _testCreateModel( + 'absolute_url_expression_files/hello.dart', + reader: absoluteReader); + + expect(model.reflectables.length).toEqual(2); + var view = + model.reflectables.first.annotations.firstWhere((a) => a.isView); + expect(view.namedParameters + .firstWhere((p) => p.name == 'templateUrl') + .value).toContain('package:other_package/template.html'); + expect(view.namedParameters.firstWhere((p) => p.name == 'template').value) + .toContain('{{greeting}}'); + expect(view.namedParameters.firstWhere((p) => p.name == 'styles').value) + .toContain('.greeting { .color: blue; }'); + + // TODO(kegluneq): Split this test out, as it is logically very different. + expect(model.reflectables[1].isFunction).toBeTrue(); + expect(model.reflectables[1].name).toEqual('hello'); + }); + + it('should inline multiple `styleUrls` values expressed as absolute urls.', + () async { + var model = + await _testCreateModel('multiple_style_urls_files/hello.dart'); + + expect(model.reflectables.isNotEmpty).toBeTrue(); + var view = + model.reflectables.first.annotations.firstWhere((a) => a.isView); + var expectStyles = expect( + view.namedParameters.firstWhere((p) => p.name == 'styles').value); + expectStyles + ..toContain('.greeting { .color: blue; }') + ..toContain('.hello { .color: red; }'); + }); + + it( + 'should not inline multiple `styleUrls` values expressed as absolute ' + 'urls.', () async { + absoluteReader.addAsset( + new AssetId('a', 'lib/template.html'), + readFile( + 'directive_processor/multiple_style_urls_files/template.html')); + absoluteReader.addAsset( + new AssetId('a', 'lib/template.css'), + readFile( + 'directive_processor/multiple_style_urls_files/template.css')); + absoluteReader.addAsset( + new AssetId('a', 'lib/template_other.css'), + readFile( + 'directive_processor/multiple_style_urls_files/template_other.css')); + var model = await _testCreateModel( + 'multiple_style_urls_not_inlined_files/hello.dart', + inlineViews: false, + reader: absoluteReader); + expect(model.reflectables.isNotEmpty).toBeTrue(); + var view = + model.reflectables.first.annotations.firstWhere((a) => a.isView); + expect(view.namedParameters.firstWhere((p) => p.name == 'styles', + orElse: () => null)).toBeNull(); + expect( + view.namedParameters.firstWhere((p) => p.name == 'styleUrls').value) + ..toContain('package:a/template.css') + ..toContain('package:a/template_other.css'); + }); + + it('should inline `templateUrl`s expressed as adjacent strings.', () async { + var model = + await _testCreateModel('split_url_expression_files/hello.dart'); + expect(model.reflectables.isNotEmpty).toBeTrue(); + var view = + model.reflectables.first.annotations.firstWhere((a) => a.isView); + expect(view.namedParameters.firstWhere((p) => p.name == 'template').value) + .toContain('{{greeting}}'); + }); + }); + + describe('interfaces', () { + it('should include implemented types', () async { + var model = await _testCreateModel('interfaces_files/soup.dart'); + + expect(model.reflectables.first.interfaces).toBeNotNull(); + expect(model.reflectables.first.interfaces.isNotEmpty).toBeTrue(); + expect(model.reflectables.first.interfaces.contains('OnChanges')) + .toBeTrue(); + expect(model.reflectables.first.interfaces.contains('AnotherInterface')) + .toBeTrue(); + }); + + it('should not include transitively implemented types', () async { + var model = await _testCreateModel('interface_chain_files/soup.dart'); + + expect(model.reflectables.first.interfaces).toBeNotNull(); + expect(model.reflectables.first.interfaces.isNotEmpty).toBeTrue(); + expect(model.reflectables.first.interfaces.contains('PrimaryInterface')) + .toBeTrue(); + expect(model.reflectables.first.interfaces.contains('SecondaryInterface')) + .toBeFalse(); + expect(model.reflectables.first.interfaces.contains('TernaryInterface')) + .toBeFalse(); + }); + + it('should not include superclasses.', () async { + var model = await _testCreateModel('superclass_files/soup.dart'); + + var interfaces = model.reflectables.first.interfaces; + expect(interfaces == null || interfaces.isEmpty).toBeTrue(); + }); + + it('should populate multiple `lifecycle` values when necessary.', () async { + var model = await _testCreateModel( + 'multiple_interface_lifecycle_files/soup.dart'); + + expect(model.reflectables.first.interfaces).toBeNotNull(); + expect(model.reflectables.first.interfaces.isNotEmpty).toBeTrue(); + expect(model.reflectables.first.interfaces.contains('OnChanges')) + .toBeTrue(); + expect(model.reflectables.first.interfaces.contains('OnDestroy')) + .toBeTrue(); + expect(model.reflectables.first.interfaces.contains('OnInit')).toBeTrue(); + }); + + it('should not populate `lifecycle` when lifecycle superclass is present.', + () async { + var model = + await _testCreateModel('superclass_lifecycle_files/soup.dart'); + + var interfaces = model.reflectables.first.interfaces; + expect(interfaces == null || interfaces.isEmpty).toBeTrue(); + }); + + it('should populate `lifecycle` with prefix when necessary.', () async { + var model = await _testCreateModel( + 'prefixed_interface_lifecycle_files/soup.dart'); + expect(model.reflectables.first.interfaces).toBeNotNull(); + expect(model.reflectables.first.interfaces.isNotEmpty).toBeTrue(); + expect(model.reflectables.first.interfaces + .firstWhere((i) => i.contains('OnChanges'), orElse: () => null)) + .toBeNotNull(); + }); + }); + + it('should not throw/hang on invalid urls', () async { + var logger = new RecordingLogger(); + var model = + await _testCreateModel('invalid_url_files/hello.dart', logger: logger); + expect(logger.hasErrors).toBeTrue(); + expect(logger.logs) + ..toContain( + 'ERROR: Uri /bad/absolute/url.html not supported from angular2|test/' + 'transform/directive_processor/invalid_url_files/hello.dart, could not ' + 'build AssetId') + ..toContain( + 'ERROR: Could not read asset at uri package:invalid/package.css from ' + 'angular2|test/transform/directive_processor/invalid_url_files/' + 'hello.dart') + ..toContain( + 'ERROR: Could not read asset at uri bad_relative_url.css from angular2|' + 'test/transform/directive_processor/invalid_url_files/hello.dart'); + }); + + it('should find and register static functions.', () async { + var model = await _testCreateModel('static_function_files/hello.dart'); + + var functionReflectable = + model.reflectables.firstWhere((i) => i.isFunction, orElse: () => null); + expect(functionReflectable)..toBeNotNull(); + expect(functionReflectable.name).toEqual('getMessage'); + }); + + it('should find direcive aliases patterns.', () async { + var logger = new RecordingLogger(); + return log.setZoned(logger, () async { + var inputId = _assetIdForPath('directive_aliases_files/hello.dart'); + var reader = new TestAssetReader(); + + var ngMeta = new NgMeta.empty(); + await createNgDeps(reader, inputId, new AnnotationMatcher(), ngMeta, + inlineViews: true); + + expect(ngMeta.aliases).toContain('alias1'); + expect(ngMeta.aliases['alias1']).toContain('HelloCmp'); + + expect(ngMeta.aliases).toContain('alias2'); + expect(ngMeta.aliases['alias2'])..toContain('HelloCmp')..toContain('Foo'); + }); + }); +} + +Future _testCreateModel(String inputPath, {List customDescriptors: const [], AssetId assetId, AssetReader reader, - List expectedLogs, - bool inlineViews: true, - bool isolate: false}) { - var testFn = isolate ? iit : it; - testFn(name, () async { - var logger = new RecordingLogger(); - await log.setZoned(logger, () async { - var inputId = _assetIdForPath(inputPath); - if (reader == null) { - reader = new TestAssetReader(); - } - if (assetId != null) { - reader.addAsset(assetId, await reader.readAsString(inputId)); - inputId = assetId; - } - var expectedNgDepsPath = path.join(path.dirname(inputPath), 'expected', - path.basename(inputPath).replaceFirst('.dart', '.ng_deps.dart')); - var expectedNgDepsId = _assetIdForPath(expectedNgDepsPath); - - var expectedAliasesPath = path.join(path.dirname(inputPath), 'expected', - path.basename(inputPath).replaceFirst('.dart', '.aliases.json')); - var expectedAliasesId = _assetIdForPath(expectedAliasesPath); - - var annotationMatcher = new AnnotationMatcher() - ..addAll(customDescriptors); - var ngMeta = new NgMeta.empty(); - var output = await createNgDeps( - reader, inputId, annotationMatcher, ngMeta, - inlineViews: inlineViews); - if (output == null) { - expect(await reader.hasInput(expectedNgDepsId)).toBeFalse(); - } else { - var expectedOutput = await reader.readAsString(expectedNgDepsId); - expect(formatter.format(output)) - .toEqual(formatter.format(expectedOutput)); - } - if (ngMeta.isEmpty) { - expect(await reader.hasInput(expectedAliasesId)).toBeFalse(); - } else { - var expectedJson = await reader.readAsString(expectedAliasesId); - expect(new JsonEncoder.withIndent(' ').convert(ngMeta.toJson())) - .toEqual(expectedJson.trim()); - } - }); - - if (expectedLogs == null) { - expect(logger.hasErrors).toBeFalse(); - } else { - expect(logger.logs, expectedLogs); + BuildLogger logger, + bool inlineViews: true}) { + if (logger == null) logger = new RecordingLogger(); + return log.setZoned(logger, () async { + var inputId = _assetIdForPath(inputPath); + if (reader == null) { + reader = new TestAssetReader(); } + if (assetId != null) { + reader.addAsset(assetId, await reader.readAsString(inputId)); + inputId = assetId; + } + + var annotationMatcher = new AnnotationMatcher()..addAll(customDescriptors); + var ngMeta = new NgMeta.empty(); + return createNgDeps(reader, inputId, annotationMatcher, ngMeta, + inlineViews: inlineViews); }); } diff --git a/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/package_soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/package_soup.ng_deps.dart deleted file mode 100644 index 64742ce501..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/package_soup.ng_deps.dart +++ /dev/null @@ -1,17 +0,0 @@ -library dinner.package_soup.ng_deps.dart; - -import 'package_soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:soup/soup.dart'; -export 'package_soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - PackageSoup, - new _ngRef.ReflectionInfo( - const [const Soup()], const [], () => new PackageSoup())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/relative_soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/relative_soup.ng_deps.dart deleted file mode 100644 index 1e3b1ea817..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/custom_metadata/expected/relative_soup.ng_deps.dart +++ /dev/null @@ -1,17 +0,0 @@ -library dinner.relative_soup.ng_deps.dart; - -import 'relative_soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'annotations/soup.dart'; -export 'relative_soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - RelativeSoup, - new _ngRef.ReflectionInfo( - const [const Soup()], const [], () => new RelativeSoup())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.aliases.json b/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.aliases.json deleted file mode 100644 index 6cc3f59507..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.aliases.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "alias1": { - "kind": "alias", - "value": [ - "HelloCmp" - ] - }, - "alias2": { - "kind": "alias", - "value": [ - "HelloCmp", - "Foo" - ] - } -} diff --git a/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.ng_deps.dart deleted file mode 100644 index d3686bfd8a..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/directive_aliases_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,25 +0,0 @@ -library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; -import 'b.dart' as b; -export 'hello.dart'; -export 'a.dart' show alias3; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - styles: const [r'''.greeting { .color: blue; }''',], - template: r'''{{greeting}}''', - templateUrl: 'template.html') - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/expected/hello.ng_deps.dart deleted file mode 100644 index c6c89b83a3..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/expected/hello.ng_deps.dart +++ /dev/null @@ -1,26 +0,0 @@ -library examples.src.hello_world.index_common_dart.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - template: r'''{{greeting}}''', - templateUrl: r'template.html', - styles: const [ - r'''.greeting { .color: blue; }''', - r'''.hello { .color: red; }''', - ]) - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/interface_chain_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/interface_chain_files/expected/soup.ng_deps.dart deleted file mode 100644 index 11125c249b..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/interface_chain_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,20 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - ChangingSoupComponent, - new _ngRef.ReflectionInfo( - const [const Component(selector: '[soup]')], - const [], - () => new ChangingSoupComponent(), - const [PrimaryInterface])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/interface_lifecycle_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/interface_lifecycle_files/expected/soup.ng_deps.dart deleted file mode 100644 index b94882d72d..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/interface_lifecycle_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,99 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - OnChangeSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.OnChanges]) - ], - const [], - () => new OnChangeSoupComponent(), - const [OnChanges])) - ..registerType( - OnDestroySoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.OnDestroy]) - ], - const [], - () => new OnDestroySoupComponent(), - const [OnDestroy])) - ..registerType( - OnCheckSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', lifecycle: const [LifecycleEvent.DoCheck]) - ], - const [], - () => new OnCheckSoupComponent(), - const [DoCheck])) - ..registerType( - OnInitSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', lifecycle: const [LifecycleEvent.OnInit]) - ], - const [], - () => new OnInitSoupComponent(), - const [OnInit])) - ..registerType( - AfterContentInitSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.AfterContentInit]) - ], - const [], - () => new AfterContentInitSoupComponent(), - const [AfterContentInit])) - ..registerType( - AfterContentCheckedSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.AfterContentChecked]) - ], - const [], - () => new AfterContentCheckedSoupComponent(), - const [AfterContentChecked])) - ..registerType( - AfterViewInitSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.AfterViewInit]) - ], - const [], - () => new AfterViewInitSoupComponent(), - const [AfterViewInit])) - ..registerType( - AfterViewCheckedSoupComponent, - new _ngRef.ReflectionInfo( - const [ - const Component( - selector: '[soup]', - lifecycle: const [LifecycleEvent.AfterViewChecked]) - ], - const [], - () => new AfterViewCheckedSoupComponent(), - const [AfterViewChecked])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/interfaces_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/interfaces_files/expected/soup.ng_deps.dart deleted file mode 100644 index 47e5762d18..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/interfaces_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -import 'package:angular2/src/core/compiler.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - ChangingSoupComponent, - new _ngRef.ReflectionInfo( - const [const Component(selector: '[soup]')], - const [], - () => new ChangingSoupComponent(), - const [OnChanges, AnotherInterface])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart deleted file mode 100644 index 8eb198dffd..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,23 +0,0 @@ -library test.transform.directive_processor.invalid_url_files.hello.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - styles: const [r'''''', r'''''',], - template: r'''''', - templateUrl: '/bad/absolute/url.html') - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/multiple_interface_lifecycle_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/multiple_interface_lifecycle_files/expected/soup.ng_deps.dart deleted file mode 100644 index 7340342dd9..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/multiple_interface_lifecycle_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -import 'package:angular2/src/core/compiler.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - MultiSoupComponent, - new _ngRef.ReflectionInfo( - const [const Component(selector: '[soup]')], - const [], - () => new MultiSoupComponent(), - const [OnChanges, OnDestroy, OnInit])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/multiple_part_files/expected/main.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/multiple_part_files/expected/main.ng_deps.dart deleted file mode 100644 index b3487d2187..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/multiple_part_files/expected/main.ng_deps.dart +++ /dev/null @@ -1,25 +0,0 @@ -library main.ng_deps.dart; - -import 'main.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -export 'main.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - Part1Component, - new _ngRef.ReflectionInfo(const [const Component(selector: '[part1]')], - const [], () => new Part1Component())) - ..registerType( - Part2Component, - new _ngRef.ReflectionInfo(const [const Component(selector: '[part2]')], - const [], () => new Part2Component())) - ..registerType( - MainComponent, - new _ngRef.ReflectionInfo(const [const Component(selector: '[main]')], - const [], () => new MainComponent())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart deleted file mode 100644 index 1224ae0b91..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,23 +0,0 @@ -library examples.src.hello_world.multiple_style_urls_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View(styles: const [ - r'''.greeting { .color: blue; }''', - r'''.hello { .color: red; }''', - ], template: r'''{{greeting}}''', templateUrl: 'template.html') - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart deleted file mode 100644 index d66d30edc1..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,23 +0,0 @@ -library examples.src.hello_world.multiple_style_urls_not_inlined_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View(styleUrls: const [ - 'package:a/template.css', - 'package:a/template_other.css' - ], templateUrl: 'package:a/template.html') - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/parameter_metadata/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/parameter_metadata/expected/soup.ng_deps.dart deleted file mode 100644 index 9f5bff77cb..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/parameter_metadata/expected/soup.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - SoupComponent, - new _ngRef.ReflectionInfo(const [ - const Component(selector: '[soup]') - ], const [ - const [String,const Tasty()], - const [const Inject(Salt)] - ], (String description, salt) => new SoupComponent(description, salt))); -} diff --git a/modules_dart/transform/test/transform/directive_processor/part_files/expected/main.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/part_files/expected/main.ng_deps.dart deleted file mode 100644 index 64cde91181..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/part_files/expected/main.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library main.ng_deps.dart; - -import 'main.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -export 'main.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - PartComponent, - new _ngRef.ReflectionInfo(const [const Component(selector: '[part]')], - const [], () => new PartComponent())) - ..registerType( - MainComponent, - new _ngRef.ReflectionInfo(const [const Component(selector: '[main]')], - const [], () => new MainComponent())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/prefixed_interface_lifecycle_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/prefixed_interface_lifecycle_files/expected/soup.ng_deps.dart deleted file mode 100644 index fcb48f2ba9..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/prefixed_interface_lifecycle_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/compiler.dart' as prefix; -import 'package:angular2/src/core/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - OnChangeSoupComponent, - new _ngRef.ReflectionInfo( - const [const Component(selector: '[soup]')], - const [], - () => new OnChangeSoupComponent(), - const [prefix.OnChanges])); -} diff --git a/modules_dart/transform/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart deleted file mode 100644 index 2501e8032b..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library examples.src.hello_world.split_url_expression_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - template: r'''{{greeting}}''', templateUrl: 'templ' 'ate.html') - ], const [], () => new HelloCmp())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/static_function_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/static_function_files/expected/hello.ng_deps.dart deleted file mode 100644 index a0e1f6540c..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/static_function_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,24 +0,0 @@ -library static_function_files.hello.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart'; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerFunction( - getMessage, - new _ngRef.ReflectionInfo(const [ - const Injectable() - ], const [ - const [const Inject(Message)] - ])) - ..registerType( - Message, - new _ngRef.ReflectionInfo( - const [const Injectable()], const [], () => new Message())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/superclass_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/superclass_files/expected/soup.ng_deps.dart deleted file mode 100644 index 7e2bd283f4..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/superclass_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,17 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - ChangingSoupComponent, - new _ngRef.ReflectionInfo(const [const Component(selector: '[soup]')], - const [], () => new ChangingSoupComponent())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/superclass_lifecycle_files/expected/soup.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/superclass_lifecycle_files/expected/soup.ng_deps.dart deleted file mode 100644 index 6862c8422c..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/superclass_lifecycle_files/expected/soup.ng_deps.dart +++ /dev/null @@ -1,18 +0,0 @@ -library dinner.soup.ng_deps.dart; - -import 'soup.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/compiler.dart'; -import 'package:angular2/src/core/metadata.dart'; -export 'soup.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - OnChangeSoupComponent, - new _ngRef.ReflectionInfo(const [const Component(selector: '[soup]')], - const [], () => new OnChangeSoupComponent())); -} diff --git a/modules_dart/transform/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart b/modules_dart/transform/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart deleted file mode 100644 index 902eacfff0..0000000000 --- a/modules_dart/transform/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart +++ /dev/null @@ -1,21 +0,0 @@ -library examples.src.hello_world.url_expression_files.ng_deps.dart; - -import 'hello.dart'; -import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; -import 'package:angular2/angular2.dart' - show Component, Directive, View, NgElement; -export 'hello.dart'; - -var _visited = false; -void initReflector() { - if (_visited) return; - _visited = true; - _ngRef.reflector - ..registerType( - HelloCmp, - new _ngRef.ReflectionInfo(const [ - const Component(selector: 'hello-app'), - const View( - template: r'''{{greeting}}''', templateUrl: 'template.html') - ], const [], () => new HelloCmp())); -}