test(dart/transform): Update tests for new codegen

Update unit tests for `bind_generator` responsibility move.
This commit is contained in:
Tim Blasi 2015-10-13 17:27:21 -07:00
parent a18358d484
commit c91fc49d01
56 changed files with 532 additions and 1450 deletions

View File

@ -9,7 +9,6 @@ import {EventBinding} from './event_binding';
// The names of these fields must be kept in sync with abstract_change_detector.ts or change
// detection will fail.
const _ALREADY_CHECKED_ACCESSOR = "alreadyChecked";
const _CONTEXT_ACCESSOR = "context";
const _PROP_BINDING_INDEX = "propertyBindingIndex";
const _DIRECTIVES_ACCESSOR = "directiveIndices";
const _DISPATCHER_ACCESSOR = "dispatcher";
@ -17,6 +16,7 @@ const _LOCALS_ACCESSOR = "locals";
const _MODE_ACCESSOR = "mode";
const _PIPES_ACCESSOR = "pipes";
const _PROTOS_ACCESSOR = "protos";
export const CONTEXT_ACCESSOR = "context";
// `context` is always first.
export const CONTEXT_INDEX = 0;
@ -49,14 +49,14 @@ export class CodegenNameUtil {
constructor(private _records: ProtoRecord[], private _eventBindings: EventBinding[],
private _directiveRecords: any[], private _utilName: string) {
this._sanitizedNames = ListWrapper.createFixedSize(this._records.length + 1);
this._sanitizedNames[CONTEXT_INDEX] = _CONTEXT_ACCESSOR;
this._sanitizedNames[CONTEXT_INDEX] = CONTEXT_ACCESSOR;
for (var i = 0, iLen = this._records.length; i < iLen; ++i) {
this._sanitizedNames[i + 1] = sanitizeName(`${this._records[i].name}${i}`);
}
for (var ebIndex = 0; ebIndex < _eventBindings.length; ++ebIndex) {
var eb = _eventBindings[ebIndex];
var names = [_CONTEXT_ACCESSOR];
var names = [CONTEXT_ACCESSOR];
for (var i = 0, iLen = eb.records.length; i < iLen; ++i) {
names.push(sanitizeName(`${eb.records[i].name}${i}_${ebIndex}`));
}

View File

@ -7,7 +7,10 @@ import 'package:angular2/src/core/metadata/view.dart' show ViewEncapsulation;
export 'package:angular2/src/core/compiler/directive_metadata.dart';
export 'package:angular2/src/core/change_detection/change_detection.dart';
export 'package:angular2/src/core/metadata/view.dart' show ViewEncapsulation;
export 'package:angular2/src/transform/common/model/annotation_model.pb.dart';
export 'package:angular2/src/transform/common/model/import_export_model.pb.dart';
export 'package:angular2/src/transform/common/model/ng_deps_model.pb.dart';
export 'package:angular2/src/transform/common/model/reflection_info_model.pb.dart';
export 'package:angular2/src/transform/common/ng_meta.dart';
CompileDirectiveMetadata createComponentMetadataForTest(
@ -26,11 +29,11 @@ CompileDirectiveMetadata createComponentMetadataForTest(
CompileDirectiveMetadata createDirectiveMetadataForTest(
{String name: 'TestMetadata',
String moduleUrl: 'asset:angular2/test/test.dart',
String selector: '[test]',
String selector: 'test',
CompileTemplateMetadata template: null}) {
return CompileDirectiveMetadata.create(
type: new CompileTypeMetadata(name: name, moduleUrl: moduleUrl),
isComponent: false,
isComponent: template != null,
dynamicLoadable: true,
selector: selector,
exportAs: null,
@ -41,3 +44,24 @@ CompileDirectiveMetadata createDirectiveMetadataForTest(
lifecycleHooks: [],
template: template);
}
CompileDirectiveMetadata createFoo([String moduleBase = 'asset:a']) =>
createComponentMetadataForTest(
name: 'FooComponent',
moduleUrl: '$moduleBase/export_cycle_files/foo.dart',
selector: 'foo',
template: 'Foo');
CompileDirectiveMetadata createBar([String moduleBase = 'asset:a']) =>
createComponentMetadataForTest(
name: 'BarComponent',
moduleUrl: '$moduleBase/export_cycle_files/bar.dart',
selector: 'bar',
template: 'Bar');
CompileDirectiveMetadata createBaz([String moduleBase = 'asset:a']) =>
createComponentMetadataForTest(
name: 'BazComponent',
moduleUrl: '$moduleBase/export_cycle_files/baz.dart',
selector: 'baz',
template: 'Baz');

View File

@ -37,32 +37,17 @@ void allTests() {
reader = new TestAssetReader();
// Establish some test NgMeta objects with one Component each.
var fooName = 'FooComponent';
var fooComponentMeta = createComponentMetadataForTest(
name: fooName,
moduleUrl: '$moduleBase/export_cycle_files/foo.dart',
selector: '[foo]',
template: 'Foo');
var fooComponentMeta = createFoo(moduleBase);
fooNgMeta = new NgMeta(ngDeps: new NgDepsModel());
fooNgMeta.types[fooName] = fooComponentMeta;
fooNgMeta.types[fooComponentMeta.type.name] = fooComponentMeta;
var barName = 'BarComponent';
var barComponentMeta = createComponentMetadataForTest(
name: barName,
moduleUrl: '$moduleBase/export_cycle_files/bar.dart',
selector: '[bar]',
template: 'Bar');
var barComponentMeta = createBar(moduleBase);
barNgMeta = new NgMeta(ngDeps: new NgDepsModel());
barNgMeta.types[barName] = barComponentMeta;
barNgMeta.types[barComponentMeta.type.name] = barComponentMeta;
var bazName = 'BazComponent';
var bazComponentMeta = createComponentMetadataForTest(
name: bazName,
moduleUrl: '$moduleBase/export_cycle_files/baz.dart',
selector: '[baz]',
template: 'Baz');
var bazComponentMeta = createBaz(moduleBase);
bazNgMeta = new NgMeta(ngDeps: new NgDepsModel());
barNgMeta.types[bazName] = bazComponentMeta;
barNgMeta.types[bazComponentMeta.type.name] = bazComponentMeta;
fooAssetId = new AssetId('a', 'lib/foo.ng_meta.json');
barAssetId = new AssetId('a', 'lib/bar.ng_meta.json');
@ -79,8 +64,8 @@ void allTests() {
expect(extracted.types).toContain('FooComponent');
expect(extracted.types).toContain('BarComponent');
expect(extracted.types['FooComponent'].selector).toEqual('[foo]');
expect(extracted.types['BarComponent'].selector).toEqual('[bar]');
expect(extracted.types['FooComponent'].selector).toEqual('foo');
expect(extracted.types['BarComponent'].selector).toEqual('bar');
});
it('should include `DirectiveMetadata` recursively from exported files.',
@ -94,9 +79,9 @@ void allTests() {
expect(extracted.types).toContain('BarComponent');
expect(extracted.types).toContain('BazComponent');
expect(extracted.types['FooComponent'].selector).toEqual('[foo]');
expect(extracted.types['BarComponent'].selector).toEqual('[bar]');
expect(extracted.types['BazComponent'].selector).toEqual('[baz]');
expect(extracted.types['FooComponent'].selector).toEqual('foo');
expect(extracted.types['BarComponent'].selector).toEqual('bar');
expect(extracted.types['BazComponent'].selector).toEqual('baz');
});
it('should handle `DirectiveMetadata` export cycles gracefully.', () async {
@ -125,8 +110,8 @@ void allTests() {
expect(extracted.types).toContain('FooComponent');
expect(extracted.types).toContain('BarComponent');
expect(extracted.types['FooComponent'].selector).toEqual('[foo]');
expect(extracted.types['BarComponent'].selector).toEqual('[bar]');
expect(extracted.types['FooComponent'].selector).toEqual('foo');
expect(extracted.types['BarComponent'].selector).toEqual('bar');
});
});

View File

@ -419,6 +419,27 @@ void allTests() {
expect(ngMeta.types['HelloCmp'].template.templateUrl)
.toEqual('asset:other_package/lib/template.html');
});
it('should handle prefixed annotations', () async {
var model =
(await _testCreateModel('prefixed_annotations_files/soup.dart'))
.ngDeps;
expect(model.reflectables.isEmpty).toBeFalse();
final annotations = model.reflectables.first.annotations;
final viewAnnotation =
annotations.firstWhere((m) => m.isView, orElse: () => null);
final componentAnnotation =
annotations.firstWhere((m) => m.isComponent, orElse: () => null);
expect(viewAnnotation).toBeNotNull();
expect(viewAnnotation.namedParameters.first.name).toEqual('template');
expect(viewAnnotation.namedParameters.first.value).toContain('SoupView');
expect(componentAnnotation).toBeNotNull();
expect(componentAnnotation.namedParameters.first.name)
.toEqual('selector');
expect(componentAnnotation.namedParameters.first.value)
.toContain('[soup]');
});
});
}

View File

@ -0,0 +1,7 @@
library dinner.soup;
import 'package:angular2/src/core/metadata.dart' as ng;
@ng.Component(selector: '[soup]')
@ng.View(template: 'SoupView')
class SoupComponent {}

View File

@ -110,7 +110,7 @@ void allTests() {
'a|web/bar.ng_deps.dart': 'event_getter_files/expected/bar.ng_deps.dart'
}),
new IntegrationTestConfig(
'should handle Directive depenedencies declared on a View.',
'should handle Directive dependencies declared on a View.',
inputs: {
'a|web/index.dart': 'directive_dep_files/index.dart',
'a|web/foo.dart': 'directive_dep_files/foo.dart',
@ -140,7 +140,30 @@ void allTests() {
outputs: {
'a|web/foo.ng_deps.dart': 'empty_ng_deps_files/expected/foo.ng_deps.dart',
'a|web/bar.ng_deps.dart': 'empty_ng_deps_files/expected/bar.ng_deps.dart'
})
}),
new IntegrationTestConfig(
'should generate setters for annotated properties.',
inputs: {
'a|web/bar.dart': 'queries_prop_annotation_files/bar.dart'
},
outputs: {
'a|web/bar.ng_deps.dart':
'queries_prop_annotation_files/expected/bar.ng_deps.dart'
}),
new IntegrationTestConfig(
'should generate setters for `queries` values in Directives.',
inputs: {
'a|web/bar.dart': 'queries_class_annotation_files/bar.dart'
},
outputs: {
'a|web/bar.ng_deps.dart':
'queries_class_annotation_files/expected/bar.ng_deps.dart'
}),
new IntegrationTestConfig(
'should handle @override annotations in properties on Directives.',
inputs: {'a|web/bar.dart': 'override_annotation_files/bar.dart'},
outputs:
{'a|web/bar.ng_deps.dart': 'override_annotation_files/expected/bar.ng_deps.dart'})
];
var cache = {};

View File

@ -1,11 +1,10 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,13 +1,12 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'baz.dart';
import 'baz.ng_deps.dart' as i1;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,13 +1,12 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'foo.dart' as prefix;
import 'foo.ng_deps.dart' as i1;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,13 +1,12 @@
library bar.ng_deps.dart;
import 'foo.template.dart' as _templates;
import 'foo.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.dart';
import 'bar.ng_deps.dart' as i1;
import 'foo.template.dart' as _templates;
export 'foo.dart';
var _visited = false;

View File

@ -1,11 +1,10 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,12 +1,11 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'foo.dart';
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -0,0 +1,10 @@
library bar;
import 'package:angular2/src/core/metadata.dart';
@Component(selector: '[soup]')
@View(template: '')
class MyComponent implements QueryFieldProvider {
@override
String queryField;
}

View File

@ -0,0 +1,30 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;
void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(
MyComponent,
new _ngRef.ReflectionInfo(
const [
const Component(selector: '[soup]'),
const View(template: ''),
_templates.HostMyComponentTemplate
],
const [],
() => new MyComponent(),
const [QueryFieldProvider],
const {
'queryField': const [override]
}));
i0.initReflector();
}

View File

@ -0,0 +1,9 @@
library bar;
import 'package:angular2/src/core/metadata.dart';
@Component(
selector: '[soup]',
queries: const {'queryField': const ContentChild('child')})
@View(template: '')
class MyComponent {}

View File

@ -0,0 +1,26 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;
void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(
MyComponent,
new _ngRef.ReflectionInfo(const [
const Component(
queries: const {'queryField': const ContentChild('child')},
selector: '[soup]'),
const View(template: ''),
_templates.HostMyComponentTemplate
], const [], () => new MyComponent()))
..registerSetters({'queryField': (o, v) => o.queryField = v});
i0.initReflector();
}

View File

@ -0,0 +1,9 @@
library bar;
import 'package:angular2/src/core/metadata.dart';
@Component(selector: '[soup]')
@View(template: '')
class MyComponent {
@ContentChild('child') String queryField;
}

View File

@ -0,0 +1,31 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;
void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(
MyComponent,
new _ngRef.ReflectionInfo(
const [
const Component(selector: '[soup]'),
const View(template: ''),
_templates.HostMyComponentTemplate
],
const [],
() => new MyComponent(),
const [],
const {
'queryField': const [const ContentChild('child')]
}))
..registerSetters({'queryField': (o, v) => o.queryField = v});
i0.initReflector();
}

View File

@ -1,11 +1,10 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,11 +1,10 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,11 +1,10 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -1,12 +1,11 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/metadata.ng_deps.dart' as i0;
import 'foo.dart' as prefix;
import 'bar.template.dart' as _templates;
export 'bar.dart';
var _visited = false;

View File

@ -4,8 +4,9 @@ import 'dart:async';
import 'dart:convert';
import 'package:barback/barback.dart';
import 'package:angular2/src/core/change_detection/codegen_name_util.dart'
show CONTEXT_ACCESSOR;
import 'package:angular2/src/core/dom/html_adapter.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/template_compiler/generator.dart';
import 'package:dart_style/dart_style.dart';
@ -13,226 +14,374 @@ import 'package:path/path.dart' as path;
import 'package:guinness/guinness.dart';
import '../common/compile_directive_metadata/ng_for.ng_meta.dart' as ngMeta;
import '../common/ng_meta_helper.dart';
import '../common/read_file.dart';
import '../common/recording_logger.dart';
var formatter = new DartFormatter();
AssetReader reader;
TestAssetReader reader;
RecordingLogger logger;
main() => allTests();
var fooComponentMeta, fooNgMeta, fooAssetId;
var barComponentMeta, barNgMeta, barAssetId;
var bazComponentMeta, bazNgMeta, bazAssetId;
/// Call after making changes to `fooNgMeta`, `barNgMeta`, or `bazNgMeta` and
/// before trying to read them from `reader`.
TestAssetReader updateReader() => reader
..addAsset(fooAssetId, JSON.encode(fooNgMeta.toJson()))
..addAsset(barAssetId, JSON.encode(barNgMeta.toJson()))
..addAsset(bazAssetId, JSON.encode(bazNgMeta.toJson()));
void allTests() {
Html5LibDomAdapter.makeCurrent();
beforeEach(() async {
final moduleBase = 'asset:a';
beforeEach(() {
reader = new TestAssetReader()
..addAsset(
new AssetId('angular2', 'lib/src/directives/ng_for.ng_meta.json'),
JSON.encode(ngMeta.ngFor));
// Establish some test NgMeta objects with one Component each.
// NOTE(kegluneq): For simplicity, the NgDepsModel objects created here are
// lacking some details that would be created by DirectiveProcessor but
// which are not used in the template compiler.
fooComponentMeta = createFoo(moduleBase);
fooNgMeta = new NgMeta(ngDeps: new NgDepsModel()
..libraryUri = 'test.foo'
..reflectables.add(new ReflectionInfoModel()..name = fooComponentMeta.type.name));
fooNgMeta.types[fooComponentMeta.type.name] = fooComponentMeta;
barComponentMeta = createBar(moduleBase);
barNgMeta = new NgMeta(ngDeps: new NgDepsModel()
..libraryUri = 'test.bar'
..reflectables.add(new ReflectionInfoModel()..name = barComponentMeta.type.name));
barNgMeta.types[barComponentMeta.type.name] = barComponentMeta;
bazComponentMeta = createBaz(moduleBase);
bazNgMeta = new NgMeta(ngDeps: new NgDepsModel()
..libraryUri = 'test.baz'
..reflectables.add(new ReflectionInfoModel()..name = bazComponentMeta.type.name));
barNgMeta.types[bazComponentMeta.type.name] = bazComponentMeta;
fooAssetId = new AssetId('a', 'lib/foo.ng_meta.json');
barAssetId = new AssetId('a', 'lib/bar.ng_meta.json');
bazAssetId = new AssetId('a', 'lib/baz.ng_meta.json');
updateReader();
});
describe('registrations', () {
noChangeDetectorTests();
changeDetectorTests();
});
}
void changeDetectorTests() {
Future<Outputs> process(AssetId assetId) {
return log.setZoned(
new RecordingLogger(), () => processTemplates(reader, assetId));
}
// TODO(tbosch): This is just a temporary test that makes sure that the dart server and
// dart browser is in sync. Change this to "not contains notifyBinding"
// when https://github.com/angular/angular/issues/3019 is solved.
it('should not always notifyDispatcher for template variables', () async {
var inputPath = 'template_compiler/ng_for_files/hello.ng_deps.dart';
var output = await (process(new AssetId('a', inputPath)));
expect(output.templatesCode).not.toContain('notifyDispatcher');
});
it('should include directives mentioned in directive aliases.', () async {
// Input 2 is the same as input1, but contains the directive aliases
// inlined.
var input1Path =
'template_compiler/directive_aliases_files/hello1.ng_deps.dart';
var input2Path =
'template_compiler/directive_aliases_files/hello2.ng_deps.dart';
// Except for the directive argument in the View annotation, the generated
// change detectors are identical.
var output1 = (await process(new AssetId('a', input1Path))).templatesCode;
var output2 = (await process(new AssetId('a', input2Path))).templatesCode;
_formatThenExpectEquals(output1, output2);
});
it('should handle `directives` regardless of annotation ordering', () async {
// Input 2 is the same as input1, but has the @View annotation listed first.
var input1Path = 'template_compiler/annotation_ordering_files/'
'component_first.ng_deps.dart';
var input2Path = 'template_compiler/annotation_ordering_files/'
'view_first.ng_deps.dart';
// Except for the type name, the generated change detectors are identical.
var output1 = (await process(new AssetId('a', input1Path)))
.templatesCode
.replaceAll('ComponentFirst', 'ViewFirst')
.replaceAll('component_first', 'view_first');
var output2 = (await process(new AssetId('a', input2Path))).templatesCode;
_formatThenExpectEquals(output1, output2);
});
}
void noChangeDetectorTests() {
Future<String> process(AssetId assetId) {
return log.setZoned(
new RecordingLogger(),
() => processTemplates(reader, assetId)
.then((outputs) => outputs.ngDepsCode));
logger = new RecordingLogger();
return log.setZoned(logger,
() => processTemplates(reader, assetId));
}
// TODO(tbosch): This is just a temporary test that makes sure that the dart
// server and dart browser is in sync.
it('should not contain notifyBinding', () async {
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<li *ng-for="#thing of things"><div>test</div></li>');
final viewAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
viewAnnotation.namedParameters.add(new NamedParameter()
..name = 'directives'
..value = 'const [NgFor]');
fooNgMeta.ngDeps.reflectables.first.annotations.add(viewAnnotation);
fooNgMeta.ngDeps.imports.add(
new ImportModel()..uri = 'package:angular2/src/directives/ng_for.dart');
reader.addAsset(new AssetId('angular2', 'lib/src/directives/ng_for.dart'),
JSON.encode(ngMeta.ngFor));
updateReader();
final outputs = await process(fooAssetId);
// TODO(kegluenq): Does this next line need to be updated as well?
expect(outputs.templatesCode).not.toContain('notifyDispatcher');
});
it('should parse simple expressions in inline templates.', () async {
var inputPath =
'template_compiler/inline_expression_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/inline_expression_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<div [a]="b">{{greeting}}</div>',
templateUrl: 'template.html');
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps).toBeNotNull();
expect(ngDeps.imports).toContain(new ImportModel()
..uri = 'foo.template.dart'
..prefix = '_templates');
expect(ngDeps.reflectables.first.annotations)
.toContain(new AnnotationModel()
..name = '_templates.HostFooComponentTemplate'
..isConstObject = true);
expect(outputs.templatesCode)
..toContain('$CONTEXT_ACCESSOR.greeting')
..toContain('$CONTEXT_ACCESSOR.b');
});
it('should parse simple methods in inline templates.', () async {
var inputPath = 'template_compiler/inline_method_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/inline_method_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<button (click)="action()">go</button>',
templateUrl: 'template.html');
updateReader();
it('should parse simple expressions in linked templates.', () async {
var inputPath = 'template_compiler/url_expression_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/url_expression_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
it('should parse simple methods in linked templates.', () async {
var inputPath = 'template_compiler/url_method_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/url_method_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps).toBeNotNull();
expect(ngDeps.imports).toContain(new ImportModel()
..uri = 'foo.template.dart'
..prefix = '_templates');
expect(ngDeps.reflectables.first.annotations)
.toContain(new AnnotationModel()
..name = '_templates.HostFooComponentTemplate'
..isConstObject = true);
expect(outputs.templatesCode)..toContain('$CONTEXT_ACCESSOR.action()');
});
it('should parse `View` directives with a single dependency.', () async {
var inputPath = 'template_compiler/one_directive_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/one_directive_files/expected/hello.ng_deps.dart');
fooComponentMeta.template =
new CompileTemplateMetadata(template: '<${barComponentMeta.selector}>');
final viewAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
viewAnnotation.namedParameters.add(new NamedParameter()
..name = 'directives'
..value = 'const [${barComponentMeta.type.name}]');
fooNgMeta.ngDeps.reflectables.first.annotations.add(viewAnnotation);
fooNgMeta.ngDeps.imports.add(new ImportModel()..uri = 'bar.dart');
barComponentMeta.template =
new CompileTemplateMetadata(template: 'BarTemplate');
updateReader();
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps).toBeNotNull();
expect(ngDeps.imports).toContain(new ImportModel()
..uri = 'foo.template.dart'
..prefix = '_templates');
expect(ngDeps.reflectables.first.annotations)
.toContain(new AnnotationModel()
..name = '_templates.HostFooComponentTemplate'
..isConstObject = true);
expect(outputs.templatesCode)
..toContain("import 'bar.dart'")
..toContain("import 'bar.template.dart'");
});
it('should handle `directives` regardless of annotation ordering', () async {
fooComponentMeta.template =
new CompileTemplateMetadata(template: '<${barComponentMeta.selector}>');
final viewAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
final directivesParameter = new NamedParameter()
..name = 'directives'
..value = 'const [${barComponentMeta.type.name}]';
viewAnnotation.namedParameters.add(directivesParameter);
final componentAnnotation = new AnnotationModel()
..name = 'Component'
..isComponent = true;
fooNgMeta.ngDeps.reflectables.first.annotations
.addAll([viewAnnotation, componentAnnotation]);
fooNgMeta.ngDeps.imports.add(new ImportModel()..uri = 'bar.dart');
barComponentMeta.template =
new CompileTemplateMetadata(template: 'BarTemplate');
updateReader();
final viewFirstOutputs = await process(fooAssetId);
fooNgMeta.ngDeps.reflectables.first.annotations.clear();
fooNgMeta.ngDeps.reflectables.first.annotations
.addAll([componentAnnotation, viewAnnotation]);
updateReader();
final componentFirstOutputs = await process(fooAssetId);
expect(viewFirstOutputs.templatesCode).toEqual(componentFirstOutputs.templatesCode);
});
it('should handle `directives` on @Component or @View', () async {
fooComponentMeta.template =
new CompileTemplateMetadata(template: '<${barComponentMeta.selector}>');
final viewAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
final directivesParameter = new NamedParameter()
..name = 'directives'
..value = 'const [${barComponentMeta.type.name}]';
viewAnnotation.namedParameters.add(directivesParameter);
final componentAnnotation = new AnnotationModel()
..name = 'Component'
..isComponent = true;
fooNgMeta.ngDeps.reflectables.first.annotations
.addAll([viewAnnotation, componentAnnotation]);
fooNgMeta.ngDeps.imports.add(new ImportModel()..uri = 'bar.dart');
barComponentMeta.template =
new CompileTemplateMetadata(template: 'BarTemplate');
updateReader();
final onViewOutputs = await process(fooAssetId);
viewAnnotation.namedParameters.clear();
componentAnnotation.namedParameters.add(directivesParameter);
updateReader();
final onComponentOutputs = await process(fooAssetId);
expect(onComponentOutputs.templatesCode).toEqual(onViewOutputs.templatesCode);
});
it('should parse `View` directives with a single prefixed dependency.',
() async {
var inputPath = 'template_compiler/with_prefix_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/with_prefix_files/expected/hello.ng_deps.dart');
fooComponentMeta.template =
new CompileTemplateMetadata(template: '<${barComponentMeta.selector}>');
final componentAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
componentAnnotation.namedParameters.add(new NamedParameter()
..name = 'directives'
..value = 'const [prefix.${barComponentMeta.type.name}]');
fooNgMeta.ngDeps.reflectables.first.annotations.add(componentAnnotation);
fooNgMeta.ngDeps.imports.add(new ImportModel()
..uri = 'bar.dart'
..prefix = 'prefix');
barComponentMeta.template =
new CompileTemplateMetadata(template: 'BarTemplate');
updateReader();
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps).toBeNotNull();
expect(ngDeps.imports).toContain(new ImportModel()
..uri = 'foo.template.dart'
..prefix = '_templates');
expect(ngDeps.reflectables.first.annotations)
.toContain(new AnnotationModel()
..name = '_templates.HostFooComponentTemplate'
..isConstObject = true);
inputPath = 'template_compiler/with_prefix_files/goodbye.ng_deps.dart';
expected = readFile(
'template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart');
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
expect(outputs.templatesCode)
..toContain("import 'bar.dart'")
..toContain("import 'bar.template.dart'");
});
it('should parse angular directives with a prefix', () async {
var inputPath =
'template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart';
var expected = readFile(
'template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart');
it('should include directives mentioned in directive aliases.', () async {
fooComponentMeta.template =
new CompileTemplateMetadata(template: '<${barComponentMeta.selector}>');
final componentAnnotation = new AnnotationModel()
..name = 'View'
..isView = true;
final directivesParam = new NamedParameter()
..name = 'directives'
..value = 'const [directiveAlias]';
componentAnnotation.namedParameters.add(directivesParam);
fooNgMeta.ngDeps.reflectables.first.annotations.add(componentAnnotation);
fooNgMeta.ngDeps.imports.add(new ImportModel()..uri = 'bar.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooNgMeta.aliases['directiveAlias'] = [barComponentMeta.type.name];
barComponentMeta.template =
new CompileTemplateMetadata(template: 'BarTemplate');
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps).toBeNotNull();
expect(ngDeps.imports).toContain(new ImportModel()
..uri = 'foo.template.dart'
..prefix = '_templates');
expect(ngDeps.reflectables.first.annotations)
.toContain(new AnnotationModel()
..name = '_templates.HostFooComponentTemplate'
..isConstObject = true);
expect(outputs.templatesCode)
..toContain("import 'bar.dart'")
..toContain("import 'bar.template.dart'");
});
it('should create the same output for multiple calls.', () async {
var inputPath =
'template_compiler/inline_expression_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/inline_expression_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<div [a]="b">{{greeting}}</div>',
templateUrl: 'template.html');
updateReader();
final firstOutputs = await process(fooAssetId);
final secondOutputs = await process(fooAssetId);
expect(firstOutputs.ngDeps).toEqual(secondOutputs.ngDeps);
expect(firstOutputs.templatesCode).toEqual(secondOutputs.templatesCode);
});
it('should generate getters for Component#outputs.', () async {
var inputPath = 'template_compiler/event_files/hello.ng_deps.dart';
var expected =
readFile('template_compiler/event_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<div>{{greeting}}</div>', templateUrl: 'template.html');
fooComponentMeta.outputs = {'eventName': 'eventName'};
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps.getters).toContain('eventName');
});
it('should generate getters for Directive#outputs.', () async {
var inputPath =
'template_compiler/directive_event_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/directive_event_files/expected/hello.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta
..template = null
..isComponent = false;
fooComponentMeta.outputs = {'eventName': 'eventName'};
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps.getters).toContain('eventName');
});
it('should generate setters for Component#inputs.', () async {
var inputPath = 'template_compiler/component_inputs_files/bar.ng_deps.dart';
var expected = readFile(
'template_compiler/component_inputs_files/expected/bar.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta.template = new CompileTemplateMetadata(
template: '<div>{{greeting}}</div>', templateUrl: 'template.html');
fooComponentMeta.inputs = {'text': 'tool-tip'};
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps.setters).toContain('text');
});
it('should generate setters for Directive#inputs.', () async {
var inputPath = 'template_compiler/directive_inputs_files/bar.ng_deps.dart';
var expected = readFile(
'template_compiler/directive_inputs_files/expected/bar.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
fooComponentMeta
..template = null
..isComponent = false;
fooComponentMeta.inputs = {'text': 'tool-tip'};
updateReader();
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps.setters).toContain('text');
});
it(
'should generate a single setter for two `Directive`s '
'with the same inputs.', () async {
var inputPath =
'template_compiler/duplicate_input_name_files/soup.ng_deps.dart';
var expected = readFile(
'template_compiler/duplicate_input_name_files/expected/soup.ng_deps.dart');
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
fooComponentMeta
..template = null
..isComponent = false;
fooComponentMeta.inputs = {'text': 'tool-tip'};
barComponentMeta
..template = null
..isComponent = false;
barComponentMeta.inputs = {'text': 'tool-tip'};
updateReader();
// TODO(kegluenq): Before committing, should this test be removed or just
// modified to check something different, maybe the created template code?
xit('should generate all expected getters, setters, & methods.', () async {
var base = 'template_compiler/registrations_files';
var inputPath = path.join(base, 'registrations.ng_deps.dart');
var expected =
readFile(path.join(base, 'expected/registrations.ng_deps.dart'));
var output = await process(new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
final outputs = await process(fooAssetId);
final ngDeps = outputs.ngDeps;
expect(ngDeps.setters).toContain('text');
expect(ngDeps.setters.length).toEqual(1);
});
}

View File

@ -1,24 +0,0 @@
library test.src.transform.template_compiler.annotation_ordering_files.component_first.ng_deps.dart;
import 'component_first.dart';
import 'package:angular2/angular2.dart'
show Component, Directive, View, NgElement;
import 'package:angular2/src/directives/ng_for.dart';
export 'component_first.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ComponentFirst,
new ReflectionInfo(const [
const Component(selector: 'hello-app'),
const View(
template: '<li *ng-for="#thing of things"><div>test</div></li>',
directives: const [NgFor])
], const [
const []
], () => new ComponentFirst()));
}

View File

@ -1,32 +0,0 @@
{
"ComponentFirst":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "ComponentFirst",
"moduleUrl": "asset:angular2/test/transform/template_compiler/ng_for_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<li *ng-for=\"#thing of things\"><div>test</div></li>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,24 +0,0 @@
library test.src.transform.template_compiler.annotation_ordering_files.view_first.ng_deps.dart;
import 'view_first.dart';
import 'package:angular2/angular2.dart'
show Component, Directive, View, NgElement;
import 'package:angular2/src/directives/ng_for.dart';
export 'view_first.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ViewFirst,
new ReflectionInfo(const [
const View(
template: '<li *ng-for="#thing of things"><div>test</div></li>',
directives: const [NgFor]),
const Component(selector: 'hello-app')
], const [
const []
], () => new ViewFirst()));
}

View File

@ -1,32 +0,0 @@
{
"ViewFirst":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "ViewFirst",
"moduleUrl": "asset:angular2/test/transform/template_compiler/ng_for_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<li *ng-for=\"#thing of things\"><div>test</div></li>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,18 +0,0 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/metadata.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ToolTip,
new ReflectionInfo(const [
const Component(
selector: '[tool-tip]', inputs: const ['text: tool-tip']),
const View(template: '<div>Tooltip</div>')
], const [], () => new ToolTip()));
}

View File

@ -1,32 +0,0 @@
{
"ToolTip":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"[tool-tip]",
"exportAs": null,
"type": {
"id": 1,
"name": "ToolTip",
"moduleUrl": "asset:template_compiler/lib/basic_inputs_files/bar.dart"
},
"changeDetection": 5,
"inputs": {"text": "tool-tip"},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<div>Tooltip</div>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,22 +0,0 @@
library bar.ng_deps.dart;
import 'bar.template.dart' as _templates;
import 'bar.dart';
import 'package:angular2/src/core/metadata.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ToolTip,
new ReflectionInfo(const [
const Component(
selector: '[tool-tip]', inputs: const ['text: tool-tip']),
const View(template: '<div>Tooltip</div>'),
_templates.HostToolTipTemplate
], const [], () => new ToolTip()))
..registerSetters({'text': (o, v) => o.text = v});
}

View File

@ -1,67 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:template_compiler/lib/directive_aliases_files/hello1.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "goodbye-app",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
},
"GoodbyeCmp":{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"goodbye-app",
"exportAs": null,
"type": {
"id": 1,
"name": "GoodbyeCmp",
"moduleUrl": "asset:template_compiler/lib/directive_aliases_files/hello1.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "Goodbye",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
},
"aliases1":{
"kind": "alias",
"value": [
"GoodbyeCmp"
]
}
}

View File

@ -1,61 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:template_compiler/lib/directive_aliases_files/hello1.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "goodbye-app",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
},
"GoodbyeCmp":{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"goodbye-app",
"exportAs": null,
"type": {
"id": 1,
"name": "GoodbyeCmp",
"moduleUrl": "asset:template_compiler/lib/directive_aliases_files/hello1.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "Goodbye",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": false,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/directive_event_files/hello.dart"
},
"changeDetection": 5,
"properties": {},
"outputs": {"eventName": "eventName"},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<button>go</button>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,17 +0,0 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/metadata.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ToolTip,
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]', inputs: const ['text: tool-tip'])
], const [], () => new ToolTip()));
}

View File

@ -1,25 +0,0 @@
{
"ToolTip":
{
"kind": "type",
"value": {
"isComponent": false,
"dynamicLoadable": true,
"selector":"[tool-tip]",
"exportAs": null,
"type": {
"id": 1,
"name": "ToolTip",
"moduleUrl": "asset:template_compiler/lib/basic_inputs_files/bar.dart"
},
"changeDetection": 5,
"inputs": {"text": "tool-tip"},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": null
}
}
}

View File

@ -1,18 +0,0 @@
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/metadata.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
ToolTip,
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]', inputs: const ['text: tool-tip'])
], const [], () => new ToolTip()))
..registerSetters({'text': (o, v) => o.text = v});
}

View File

@ -1,25 +0,0 @@
library dinner.soup.ng_deps.dart;
import 'package:angular2/src/core/metadata.dart';
import 'soup.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
SoupDirective,
new ReflectionInfo(const [
const Directive(
selector: 'soup',
componentServices: const [SaladDirective],
inputs: const ['menu'])
], const [], () => new SoupDirective()))
..registerType(
SaladDirective,
new ReflectionInfo(const [
const Directive(selector: 'salad', inputs: const ['menu'])
], const [], () => new SaladDirective()))
..registerSetters({'menu': (o, v) => o.menu = v});
}

View File

@ -1,24 +0,0 @@
library dinner.soup.ng_deps.dart;
import 'package:angular2/src/core/metadata.dart';
import 'soup.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
SoupDirective,
new ReflectionInfo(const [
const Directive(
selector: 'soup',
componentServices: const [SaladDirective],
inputs: const ['menu'])
], const [], () => new SoupDirective()))
..registerType(
SaladDirective,
new ReflectionInfo(const [
const Directive(selector: 'salad', inputs: const ['menu'])
], const [], () => new SaladDirective()));
}

View File

@ -1,48 +0,0 @@
{
"SoupDirective":
{
"kind": "type",
"value": {
"isComponent": false,
"dynamicLoadable": true,
"selector":"soup",
"exportAs": null,
"type": {
"id": 1,
"name": "SoupDirective",
"moduleUrl": "asset:template_compiler/test/duplicate_input_name_files/soup.dart"
},
"changeDetection": 5,
"inputs": {"menu": "menu"},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": null
}
},
"SaladDirective":
{
"kind": "type",
"value": {
"isComponent": false,
"dynamicLoadable": true,
"selector":"salad",
"exportAs": null,
"type": {
"id": 1,
"name": "SaladDirective",
"moduleUrl": "asset:template_compiler/test/duplicate_input_name_files/soup.dart"
},
"changeDetection": 5,
"inputs": {"menu": "menu"},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": null
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/event_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {"eventName": "eventName"},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<button>go</button>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/inline_expression_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<div [a]=\"b\">{{greeting}}</div>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/inline_method_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<button (click)=\"action()\">go</button>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,23 +0,0 @@
library test.src.transform.template_compiler.ng_for_files.hello.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show Component, Directive, View, NgElement;
import 'package:angular2/src/directives/ng_for.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
HelloCmp,
new ReflectionInfo(const [
const Component(selector: 'hello-app'),
const View(
template: '<li *ng-for="#thing of things"><div>test</div></li>',
directives: const [NgFor])
], const [
const []
], () => new HelloCmp()));
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/ng_for_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<li *ng-for=\"#thing of things\"><div>test</div></li>",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,61 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/one_directive_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "goodbye-app",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
},
"GoodbyeCmp":{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"goodbye-app",
"exportAs": null,
"type": {
"id": 1,
"name": "GoodbyeCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/one_directive_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "Goodbye",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,106 +0,0 @@
{
"DependencyCmp": {
"kind": "type",
"value": {
"id": "DependencyCmp",
"selector": "dependency",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": null,
"readAttributes": null,
"type": null,
"exportAs": null,
"callOnDestroy": null,
"callDoCheck": null,
"callOnInit": null,
"callOnChanges": null,
"callAfterContentInit": null,
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"outputs": ["dependencyEventName"],
"changeDetection": null,
"version": 1
}
},
"DirectiveProps": {
"kind": "type",
"value": {
"id": "DirectiveProps",
"selector": "[dir-props]",
"compileChildren": true,
"hostProperties": {"hprop": "hprop"},
"hostListeners": {},
"hostAttributes": {},
"inputs": ["prop"],
"readAttributes": null,
"type": null,
"exportAs": null,
"callOnDestroy": null,
"callDoCheck": null,
"callOnInit": null,
"callOnChanges": null,
"callAfterContentInit": null,
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"outpus": null,
"changeDetection": null,
"version": 1
}
},
"DirectiveEvents": {
"kind": "type",
"value": {
"id": "DirectiveEvents",
"selector": "[dir-events]",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {"subevent": "doAThing()"},
"hostAttributes": {},
"inputs": [],
"readAttributes": null,
"type": null,
"exportAs": null,
"callOnDestroy": null,
"callDoCheck": null,
"callOnInit": null,
"callOnChanges": null,
"callAfterContentInit": null,
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"outputs": null,
"changeDetection": null,
"version": 1
}
},
"NgFor": {
"kind": "type",
"value": {
"id": "NgFor",
"selector": "[ng-for][ng-for-of]",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": ["ngForOf"],
"readAttributes": null,
"type": null,
"exportAs": null,
"callOnDestroy": null,
"callDoCheck": true,
"callOnInit": null,
"callOnChanges": null,
"callAfterContentInit": null,
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"outputs": null,
"changeDetection": null,
"version": 1
}
}
}

View File

@ -1,210 +0,0 @@
{
"TextBindingsCmp": {
"kind": "type",
"value": {
"id": "TextBindingsCmp",
"selector": "text",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": null,
"readAttributes": null,
"type": null,
"exportAs": null,
"callOnDestroy": null,
"callDoCheck": null,
"callOnInit": null,
"callOnChanges": null,
"callAfterContentInit": null,
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"outputs": null,
"changeDetection": null,
"version": 1
}
},
"PropertyBindingsCmp": {
"kind": "type",
"value": {
"id": "PropertyBindingsCmp",
"selector": "props",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 0,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
},
"EventsCmp": {
"kind": "type",
"value": {
"id": "EventsCmp",
"selector": "outputs",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": ["eventName"],
"changeDetection": null,
"version": 1
}
},
"SubEventsCmp": {
"kind": "type",
"value": {
"id": "SubEventsCmp",
"selector": "outputs",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
},
"TemplateEventsCmp": {
"kind": "type",
"value": {
"id": "TemplateEventsCmp",
"selector": "template-events",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
},
"DirectivePropsCmp": {
"kind": "type",
"value": {
"id": "DirectivePropsCmp",
"selector": "directive-props-cmp",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
},
"DirectiveEventsCmp": {
"kind": "type",
"value": {
"id": "DirectiveEventsCmp",
"selector": "directive-events-cmp",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
},
"RecursiveCmp": {
"kind": "type",
"value": {
"id": "RecursiveCmp",
"selector": "recursive-cmp",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callDoCheck": false,
"callOnInit": false,
"callOnChanges": false,
"callAfterContentInit": false,
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"outputs": [],
"changeDetection": null,
"version": 1
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/url_expression_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "{{greeting}}",
"templateUrl": "template.html",
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/url_method_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "<button (click)=\"action()\">go</button>",
"templateUrl": "template.html",
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1 +0,0 @@
<button (click)="action()">go</button>

View File

@ -1,23 +0,0 @@
library angular2.test.transform.template_compiler.with_prefix_files.ng2_prefix.ng_deps.dart;
import 'ng2_prefix.template.dart' as _templates;
import 'ng2_prefix.dart';
import 'package:angular2/angular2.dart' as ng2
show Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
MyApp,
new ReflectionInfo(const [
const ng2.Component(selector: 'my-app'),
const ng2.View(template: 'MyApp {{name}}'),
_templates.HostMyAppTemplate
], const [
const []
], () => new MyApp()));
}

View File

@ -1,31 +0,0 @@
{
"GoodbyeCmp":{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"goodbye-app",
"exportAs": null,
"type": {
"id": 1,
"name": "GoodbyeCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/with_prefix_files/goodbye.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "Goodbye {{name}}",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"HelloCmp":
{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"hello-app",
"exportAs": null,
"type": {
"id": 1,
"name": "HelloCmp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/with_prefix_files/hello.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "goodbye-app",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}

View File

@ -1,20 +0,0 @@
library angular2.test.transform.template_compiler.with_prefix_files.ng2_prefix.ng_deps.dart;
import 'ng2_prefix.dart';
import 'package:angular2/angular2.dart' as ng2
show Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(
MyApp,
new ReflectionInfo(const [
const ng2.Component(selector: 'my-app'),
const ng2.View(template: 'MyApp {{name}}')
], const [
const []
], () => new MyApp()));
}

View File

@ -1,31 +0,0 @@
{
"MyApp":{
"kind": "type",
"value": {
"isComponent": true,
"dynamicLoadable": true,
"selector":"my-app",
"exportAs": null,
"type": {
"id": 1,
"name": "MyApp",
"moduleUrl": "asset:angular2/test/transform/template_compiler/with_prefix_files/ng2_prefix.dart"
},
"changeDetection": 5,
"inputs": {},
"outputs": {},
"hostListeners": {},
"hostProperties": {},
"hostAttributes": {},
"lifecycleHooks": [],
"template": {
"encapsulation": 0,
"template": "MyApp {{name}}",
"templateUrl": null,
"styles": null,
"styleUrls": null,
"ngContentSelectors": null
}
}
}
}