revert(format): Revert "chore(format): update to latest formatter"

This reverts commit 03627aa84d.
This commit is contained in:
Alex Rickabaugh
2016-04-12 09:40:37 -07:00
parent 03627aa84d
commit 60727c4d2b
527 changed files with 19247 additions and 13970 deletions

View File

@ -1,10 +1,31 @@
import {ddescribe, describe, xdescribe, it, iit, xit, expect, beforeEach, afterEach, AsyncTestCompleter, inject, beforeEachProviders} from 'angular2/testing_internal';
import {
ddescribe,
describe,
xdescribe,
it,
iit,
xit,
expect,
beforeEach,
afterEach,
AsyncTestCompleter,
inject,
beforeEachProviders
} from 'angular2/testing_internal';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {Type, isPresent, isBlank, stringify, isString, IS_DART} from 'angular2/src/facade/lang';
import {MapWrapper, SetWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {
MapWrapper,
SetWrapper,
ListWrapper,
StringMapWrapper
} from 'angular2/src/facade/collection';
import {RuntimeMetadataResolver} from 'angular2/src/compiler/runtime_metadata';
import {TemplateCompiler, NormalizedComponentWithViewDirectives} from 'angular2/src/compiler/template_compiler';
import {
TemplateCompiler,
NormalizedComponentWithViewDirectives
} from 'angular2/src/compiler/template_compiler';
import {CompileDirectiveMetadata} from 'angular2/src/compiler/directive_metadata';
import {evalModule} from './eval_module';
import {SourceModule, moduleRef} from 'angular2/src/compiler/source_module';
@ -19,7 +40,12 @@ import {Locals, ChangeDetectorGenConfig} from 'angular2/src/core/change_detectio
import {Component, Directive, provide, RenderComponentType} from 'angular2/core';
import {TEST_PROVIDERS} from './test_bindings';
import {codeGenValueFn, codeGenFnHeader, codeGenExportVariable, MODULE_SUFFIX} from 'angular2/src/compiler/util';
import {
codeGenValueFn,
codeGenFnHeader,
codeGenExportVariable,
MODULE_SUFFIX
} from 'angular2/src/compiler/util';
import {PipeTransform, WrappedValue, Injectable, Pipe} from 'angular2/core';
@ -42,11 +68,11 @@ export function main() {
var runtimeMetadataResolver: RuntimeMetadataResolver;
beforeEachProviders(() => TEST_PROVIDERS);
beforeEach(inject(
[TemplateCompiler, RuntimeMetadataResolver], (_compiler, _runtimeMetadataResolver) => {
compiler = _compiler;
runtimeMetadataResolver = _runtimeMetadataResolver;
}));
beforeEach(inject([TemplateCompiler, RuntimeMetadataResolver],
(_compiler, _runtimeMetadataResolver) => {
compiler = _compiler;
runtimeMetadataResolver = _runtimeMetadataResolver;
}));
describe('compile templates', () => {
@ -62,96 +88,100 @@ export function main() {
}));
it('should compile host components', inject([AsyncTestCompleter], (async) => {
compile([CompWithBindingsAndStylesAndPipes]).then((humanizedView) => {
expect(humanizedView['styles']).toEqual([]);
expect(humanizedView['elements']).toEqual(['<comp-a>']);
expect(humanizedView['pipes']).toEqual({});
expect(humanizedView['cd']).toEqual(['prop(title)=someHostValue']);
async.done();
});
compile([CompWithBindingsAndStylesAndPipes])
.then((humanizedView) => {
expect(humanizedView['styles']).toEqual([]);
expect(humanizedView['elements']).toEqual(['<comp-a>']);
expect(humanizedView['pipes']).toEqual({});
expect(humanizedView['cd']).toEqual(['prop(title)=someHostValue']);
async.done();
});
}));
it('should compile nested components', inject([AsyncTestCompleter], (async) => {
compile([CompWithBindingsAndStylesAndPipes]).then((humanizedView) => {
var componentView = humanizedView['componentViews'][0];
expect(componentView['styles']).toEqual(['div {color: red}']);
expect(componentView['elements']).toEqual(['<a>']);
expect(componentView['pipes']).toEqual({'uppercase': stringify(UpperCasePipe)});
expect(componentView['cd']).toEqual(['prop(href)=SOMECTXVALUE']);
compile([CompWithBindingsAndStylesAndPipes])
.then((humanizedView) => {
var componentView = humanizedView['componentViews'][0];
expect(componentView['styles']).toEqual(['div {color: red}']);
expect(componentView['elements']).toEqual(['<a>']);
expect(componentView['pipes']).toEqual({'uppercase': stringify(UpperCasePipe)});
expect(componentView['cd']).toEqual(['prop(href)=SOMECTXVALUE']);
async.done();
});
async.done();
});
}));
it('should compile components at various nesting levels',
inject([AsyncTestCompleter], (async) => {
compile([CompWith2NestedComps, Comp1, Comp2]).then((humanizedView) => {
expect(humanizedView['elements']).toEqual(['<comp-with-2nested>']);
expect(humanizedView['componentViews'][0]['elements']).toEqual([
'<comp1>', '<comp2>'
]);
expect(humanizedView['componentViews'][0]['componentViews'][0]['elements']).toEqual([
'<a>', '<comp2>'
]);
expect(humanizedView['componentViews'][0]['componentViews'][1]['elements']).toEqual([
'<b>'
]);
compile([CompWith2NestedComps, Comp1, Comp2])
.then((humanizedView) => {
expect(humanizedView['elements']).toEqual(['<comp-with-2nested>']);
expect(humanizedView['componentViews'][0]['elements'])
.toEqual(['<comp1>', '<comp2>']);
expect(humanizedView['componentViews'][0]['componentViews'][0]['elements'])
.toEqual(['<a>', '<comp2>']);
expect(humanizedView['componentViews'][0]['componentViews'][1]['elements'])
.toEqual(['<b>']);
async.done();
});
async.done();
});
}));
it('should compile recursive components', inject([AsyncTestCompleter], (async) => {
compile([TreeComp]).then((humanizedView) => {
expect(humanizedView['elements']).toEqual(['<tree>']);
expect(humanizedView['componentViews'][0]['embeddedViews'][0]['elements']).toEqual([
'<tree>'
]);
expect(humanizedView['componentViews'][0]['embeddedViews'][0]['componentViews'][0]
['embeddedViews'][0]['elements'])
.toEqual(['<tree>']);
compile([TreeComp])
.then((humanizedView) => {
expect(humanizedView['elements']).toEqual(['<tree>']);
expect(humanizedView['componentViews'][0]['embeddedViews'][0]['elements'])
.toEqual(['<tree>']);
expect(humanizedView['componentViews'][0]['embeddedViews'][0]['componentViews']
[0]['embeddedViews'][0]['elements'])
.toEqual(['<tree>']);
async.done();
});
async.done();
});
}));
it('should compile embedded templates', inject([AsyncTestCompleter], (async) => {
compile([CompWithEmbeddedTemplate]).then((humanizedView) => {
var embeddedView = humanizedView['componentViews'][0]['embeddedViews'][0];
expect(embeddedView['elements']).toEqual(['<a>']);
expect(embeddedView['cd']).toEqual(['prop(href)=someEmbeddedValue']);
compile([CompWithEmbeddedTemplate])
.then((humanizedView) => {
var embeddedView = humanizedView['componentViews'][0]['embeddedViews'][0];
expect(embeddedView['elements']).toEqual(['<a>']);
expect(embeddedView['cd']).toEqual(['prop(href)=someEmbeddedValue']);
async.done();
});
async.done();
});
}));
it('should dedup directives', inject([AsyncTestCompleter], (async) => {
compile([CompWithDupDirectives, TreeComp]).then((humanizedView) => {
expect(humanizedView['componentViews'][0]['componentViews'].length).toBe(1);
async.done();
compile([CompWithDupDirectives, TreeComp])
.then((humanizedView) => {
expect(humanizedView['componentViews'][0]['componentViews'].length).toBe(1);
async.done();
});
});
}));
}
describe('compileHostComponentRuntime', () => {
function compile(components: Type[]): Promise<any[]> {
return compiler.compileHostComponentRuntime(components[0])
.then(
(compiledHostTemplate) => humanizeViewFactory(compiledHostTemplate.viewFactory));
.then((compiledHostTemplate) =>
humanizeViewFactory(compiledHostTemplate.viewFactory));
}
describe('no jit', () => {
beforeEachProviders(() => [provide(ChangeDetectorGenConfig, {
useValue: new ChangeDetectorGenConfig(true, false, false)
})]);
beforeEachProviders(() => [
provide(ChangeDetectorGenConfig,
{useValue: new ChangeDetectorGenConfig(true, false, false)})
]);
runTests(compile);
});
describe('jit', () => {
beforeEachProviders(() => [provide(ChangeDetectorGenConfig, {
useValue: new ChangeDetectorGenConfig(true, false, true)
})]);
beforeEachProviders(() => [
provide(ChangeDetectorGenConfig,
{useValue: new ChangeDetectorGenConfig(true, false, true)})
]);
runTests(compile);
});
@ -173,13 +203,15 @@ export function main() {
inject([AsyncTestCompleter, XHR], (async, xhr: MockXHR) => {
// Expecting only one xhr...
xhr.expect('package:angular2/test/compiler/compUrl.html', '<a>');
compile([CompWithTemplateUrl]).then((humanizedView0) => {
return compile([CompWithTemplateUrl]).then((humanizedView1) => {
expect(humanizedView0['componentViews'][0]['elements']).toEqual(['<a>']);
expect(humanizedView1['componentViews'][0]['elements']).toEqual(['<a>']);
async.done();
});
});
compile([CompWithTemplateUrl])
.then((humanizedView0) => {
return compile([CompWithTemplateUrl])
.then((humanizedView1) => {
expect(humanizedView0['componentViews'][0]['elements']).toEqual(['<a>']);
expect(humanizedView1['componentViews'][0]['elements']).toEqual(['<a>']);
async.done();
});
});
xhr.flush();
}));
@ -203,20 +235,19 @@ export function main() {
});
describe('compileTemplatesCodeGen', () => {
function normalizeComponent(component: Type):
Promise<NormalizedComponentWithViewDirectives> {
function normalizeComponent(
component: Type): Promise<NormalizedComponentWithViewDirectives> {
var compAndViewDirMetas =
[runtimeMetadataResolver.getDirectiveMetadata(component)].concat(
runtimeMetadataResolver.getViewDirectivesMetadata(component));
var upperCasePipeMeta = runtimeMetadataResolver.getPipeMetadata(UpperCasePipe);
upperCasePipeMeta.type.moduleUrl = `package:${THIS_MODULE_ID}${MODULE_SUFFIX}`;
return PromiseWrapper
.all(compAndViewDirMetas.map(meta => compiler.normalizeDirectiveMetadata(meta)))
.then(
(normalizedCompAndViewDirMetas: CompileDirectiveMetadata[]) =>
new NormalizedComponentWithViewDirectives(
normalizedCompAndViewDirMetas[0], normalizedCompAndViewDirMetas.slice(1),
[upperCasePipeMeta]));
return PromiseWrapper.all(compAndViewDirMetas.map(
meta => compiler.normalizeDirectiveMetadata(meta)))
.then((normalizedCompAndViewDirMetas: CompileDirectiveMetadata[]) =>
new NormalizedComponentWithViewDirectives(
normalizedCompAndViewDirMetas[0],
normalizedCompAndViewDirMetas.slice(1), [upperCasePipeMeta]));
}
function compile(components: Type[]): Promise<any[]> {
@ -224,8 +255,8 @@ export function main() {
.then((normalizedCompWithViewDirMetas: NormalizedComponentWithViewDirectives[]) => {
var sourceModule = compiler.compileTemplatesCodeGen(normalizedCompWithViewDirMetas);
var sourceWithImports =
testableTemplateModule(
sourceModule, normalizedCompWithViewDirMetas[0].component)
testableTemplateModule(sourceModule,
normalizedCompWithViewDirMetas[0].component)
.getSourceWithImports();
return evalModule(sourceWithImports.source, sourceWithImports.imports, null);
});
@ -249,9 +280,8 @@ export function main() {
it('should normalize the template',
inject([AsyncTestCompleter, XHR], (async, xhr: MockXHR) => {
xhr.expect('package:angular2/test/compiler/compUrl.html', 'loadedTemplate');
compiler
.normalizeDirectiveMetadata(
runtimeMetadataResolver.getDirectiveMetadata(CompWithTemplateUrl))
compiler.normalizeDirectiveMetadata(
runtimeMetadataResolver.getDirectiveMetadata(CompWithTemplateUrl))
.then((meta: CompileDirectiveMetadata) => {
expect(meta.template.template).toEqual('loadedTemplate');
async.done();
@ -390,8 +420,8 @@ export class Comp1 {
export class CompWith2NestedComps {
}
function testableTemplateModule(
sourceModule: SourceModule, normComp: CompileDirectiveMetadata): SourceModule {
function testableTemplateModule(sourceModule: SourceModule,
normComp: CompileDirectiveMetadata): SourceModule {
var testableSource = `
${sourceModule.sourceWithModuleRefs}
${codeGenFnHeader(['_'], '_run')}{
@ -455,11 +485,11 @@ export function humanizeViewFactory(
}
var viewManager = new SpyAppViewManager();
viewManager.spy('createRenderComponentType')
.andCallFake((encapsulation: ViewEncapsulation, styles: Array<string|any[]>) => {
.andCallFake((encapsulation: ViewEncapsulation, styles: Array<string | any[]>) => {
return new RenderComponentType('someId', encapsulation, styles);
});
var view: AppView = viewFactory(
new RecordingRenderer([]), viewManager, containerAppElement, [], null, null, null);
var view: AppView = viewFactory(new RecordingRenderer([]), viewManager, containerAppElement, [],
null, null, null);
return humanizeView(view, cachedResults);
}
@ -471,11 +501,9 @@ class RecordingRenderer extends SpyRenderer {
super();
this.spy('renderComponent')
.andCallFake((componentProto) => new RecordingRenderer(componentProto.styles));
this.spy('setElementProperty').andCallFake((el, prop, value) => {
this.props.push(`prop(${prop})=${value}`);
});
this.spy('createElement').andCallFake((parent, elName) => {
this.elements.push(`<${elName}>`);
});
this.spy('setElementProperty')
.andCallFake((el, prop, value) => { this.props.push(`prop(${prop})=${value}`); });
this.spy('createElement')
.andCallFake((parent, elName) => { this.elements.push(`<${elName}>`); });
}
}