feat: adjust formatting for clang-format v1.0.19.

This commit is contained in:
Martin Probst 2015-06-12 07:50:45 -07:00
parent 1c2abbc61d
commit a6e7123995
50 changed files with 363 additions and 350 deletions

View File

@ -1,12 +1,6 @@
export class Test { export class Test {
firstItem; firstItem;
constructor() { constructor() { this.doStuff(); }
this.doStuff(); otherMethod() {}
} doStuff() {}
otherMethod() {
}
doStuff() {
}
} }

View File

@ -20,19 +20,15 @@ export class MyClass {
* Create a new MyClass * Create a new MyClass
* @param {String} name The name to say hello to * @param {String} name The name to say hello to
*/ */
constructor(name) { constructor(name) { this.message = 'hello ' + name; }
this.message = 'hello ' + name;
}
/** /**
* Return a greeting message * Return a greeting message
*/ */
greet() { greet() { return this.message; }
return this.message;
}
} }
/** /**
* An exported function * An exported function
*/ */
export var myFn = (val:number) => return val*2; export var myFn = (val: number) => return val * 2;

View File

@ -45,9 +45,9 @@ function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): P
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) { function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE && return ListWrapper.find(rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE &&
rr.mode === r.mode && rr.funcOrValue === r.funcOrValue && rr.mode === r.mode && rr.funcOrValue === r.funcOrValue &&
rr.contextIndex === r.contextIndex && rr.contextIndex === r.contextIndex &&
ListWrapper.equals(rr.args, r.args)); ListWrapper.equals(rr.args, r.args));
} }
function _replaceIndices(r: ProtoRecord, selfIndex: number, indexMap: Map<any, any>) { function _replaceIndices(r: ProtoRecord, selfIndex: number, indexMap: Map<any, any>) {

View File

@ -3,8 +3,20 @@ import {BindingRecord} from './binding_record';
import {DirectiveIndex} from './directive_record'; import {DirectiveIndex} from './directive_record';
export enum RecordType { export enum RecordType {
SELF, CONST, PRIMITIVE_OP, PROPERTY, LOCAL, INVOKE_METHOD, INVOKE_CLOSURE, KEYED_ACCESS, PIPE, SELF,
BINDING_PIPE, INTERPOLATE, SAFE_PROPERTY, SAFE_INVOKE_METHOD, DIRECTIVE_LIFECYCLE CONST,
PRIMITIVE_OP,
PROPERTY,
LOCAL,
INVOKE_METHOD,
INVOKE_CLOSURE,
KEYED_ACCESS,
PIPE,
BINDING_PIPE,
INTERPOLATE,
SAFE_PROPERTY,
SAFE_INVOKE_METHOD,
DIRECTIVE_LIFECYCLE
} }
export class ProtoRecord { export class ProtoRecord {

View File

@ -101,7 +101,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
[NgZone]), [NgZone]),
bind(ShadowDomStrategy) bind(ShadowDomStrategy)
.toFactory((styleUrlResolver, doc) => .toFactory((styleUrlResolver, doc) =>
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head), new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
[StyleUrlResolver, DOCUMENT_TOKEN]), [StyleUrlResolver, DOCUMENT_TOKEN]),
DomRenderer, DomRenderer,
DefaultDomCompiler, DefaultDomCompiler,

View File

@ -348,15 +348,18 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE
} }
function _createElementBinder(protoView, boundElementIndex, renderElementBinder, function _createElementBinder(protoView, boundElementIndex, renderElementBinder,
protoElementInjector, componentDirectiveBinding, directiveBindings): ElementBinder { protoElementInjector, componentDirectiveBinding,
directiveBindings): ElementBinder {
var parent = null; var parent = null;
if (renderElementBinder.parentIndex !== -1) { if (renderElementBinder.parentIndex !== -1) {
parent = protoView.elementBinders[renderElementBinder.parentIndex]; parent = protoView.elementBinders[renderElementBinder.parentIndex];
} }
var directiveVariableBindings = createDirectiveVariableBindings(renderElementBinder, directiveBindings); var directiveVariableBindings =
var elBinder = protoView.bindElement(parent, renderElementBinder.distanceToParent, createDirectiveVariableBindings(renderElementBinder, directiveBindings);
protoElementInjector, directiveVariableBindings, componentDirectiveBinding); var elBinder =
protoView.bindElement(parent, renderElementBinder.distanceToParent, protoElementInjector,
directiveVariableBindings, componentDirectiveBinding);
protoView.bindEvent(renderElementBinder.eventBindings, boundElementIndex, -1); protoView.bindEvent(renderElementBinder.eventBindings, boundElementIndex, -1);
// variables // variables
// The view's locals needs to have a full set of variable names at construction time // The view's locals needs to have a full set of variable names at construction time
@ -369,8 +372,9 @@ function _createElementBinder(protoView, boundElementIndex, renderElementBinder,
return elBinder; return elBinder;
} }
export function createDirectiveVariableBindings(renderElementBinder:renderApi.ElementBinder, export function createDirectiveVariableBindings(
directiveBindings:List<DirectiveBinding>): Map<String, number> { renderElementBinder: renderApi.ElementBinder,
directiveBindings: List<DirectiveBinding>): Map<String, number> {
var directiveVariableBindings = MapWrapper.create(); var directiveVariableBindings = MapWrapper.create();
MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => { MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => {
var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs); var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs);
@ -388,7 +392,8 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
if (_directiveExportAs(directive) == exportAs) { if (_directiveExportAs(directive) == exportAs) {
if (isPresent(matchedDirective)) { if (isPresent(matchedDirective)) {
throw new BaseException(`More than one directive have exportAs = '${exportAs}'. Directives: [${matchedDirective.displayName}, ${directive.displayName}]`); throw new BaseException(
`More than one directive have exportAs = '${exportAs}'. Directives: [${matchedDirective.displayName}, ${directive.displayName}]`);
} }
matchedDirectiveIndex = i; matchedDirectiveIndex = i;
@ -403,9 +408,10 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
return matchedDirectiveIndex; return matchedDirectiveIndex;
} }
function _directiveExportAs(directive):string { function _directiveExportAs(directive): string {
var directiveExportAs = directive.metadata.exportAs; var directiveExportAs = directive.metadata.exportAs;
if (isBlank(directiveExportAs) && directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) { if (isBlank(directiveExportAs) &&
directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
return "$implicit"; return "$implicit";
} else { } else {
return directiveExportAs; return directiveExportAs;

View File

@ -143,9 +143,7 @@ export class NgZone {
errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone, errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone,
{onError: function(e) { ngZone._onError(this, e) }}); {onError: function(e) { ngZone._onError(this, e) }});
} else { } else {
errorHandling = { errorHandling = {onError: function(e) { ngZone._onError(this, e) }};
onError: function(e) { ngZone._onError(this, e) }
};
} }
return zone.fork(errorHandling) return zone.fork(errorHandling)

View File

@ -240,7 +240,7 @@ export function normalizeBlank(obj) {
return isBlank(obj) ? null : obj; return isBlank(obj) ? null : obj;
} }
export function normalizeBool(obj:boolean):boolean { export function normalizeBool(obj: boolean): boolean {
return isBlank(obj) ? false : obj; return isBlank(obj) ? false : obj;
} }

View File

@ -1,12 +1,12 @@
export enum RequestModesOpts { Cors, NoCors, SameOrigin }; export enum RequestModesOpts {Cors, NoCors, SameOrigin};
export enum RequestCacheOpts { Default, NoStore, Reload, NoCache, ForceCache, OnlyIfCached }; export enum RequestCacheOpts {Default, NoStore, Reload, NoCache, ForceCache, OnlyIfCached};
export enum RequestCredentialsOpts { Omit, SameOrigin, Include }; export enum RequestCredentialsOpts {Omit, SameOrigin, Include};
export enum RequestMethods { GET, POST, PUT, DELETE, OPTIONS, HEAD }; export enum RequestMethods {GET, POST, PUT, DELETE, OPTIONS, HEAD};
export enum ReadyStates { UNSENT, OPEN, HEADERS_RECEIVED, LOADING, DONE, CANCELLED }; export enum ReadyStates {UNSENT, OPEN, HEADERS_RECEIVED, LOADING, DONE, CANCELLED};
export enum ResponseTypes { Basic, Cors, Default, Error, Opaque } export enum ResponseTypes {Basic, Cors, Default, Error, Opaque}

View File

@ -39,7 +39,7 @@ export class DomProtoView {
(isPresent(this.element) && DOM.hasClass(this.element, NG_BINDING_CLASS)) ? 1 : 0; (isPresent(this.element) && DOM.hasClass(this.element, NG_BINDING_CLASS)) ? 1 : 0;
this.boundTextNodeCount = this.boundTextNodeCount =
ListWrapper.reduce(elementBinders, (prevCount: number, elementBinder: ElementBinder) => ListWrapper.reduce(elementBinders, (prevCount: number, elementBinder: ElementBinder) =>
prevCount + elementBinder.textNodeIndices.length, prevCount + elementBinder.textNodeIndices.length,
0); 0);
this.rootNodeCount = this.rootNodeCount =
this.isTemplateElement ? DOM.childNodes(DOM.content(this.element)).length : 1; this.isTemplateElement ? DOM.childNodes(DOM.content(this.element)).length : 1;

View File

@ -86,7 +86,7 @@ function _getAppBindings() {
.toValue(appDoc), .toValue(appDoc),
bind(ShadowDomStrategy) bind(ShadowDomStrategy)
.toFactory((styleUrlResolver, doc) => .toFactory((styleUrlResolver, doc) =>
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head), new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
[StyleUrlResolver, DOCUMENT_TOKEN]), [StyleUrlResolver, DOCUMENT_TOKEN]),
DomRenderer, DomRenderer,
DefaultDomCompiler, DefaultDomCompiler,

View File

@ -11,8 +11,7 @@ import {createTestInjector, FunctionWithParamTokens, inject} from './test_inject
export {inject} from './test_injector'; export {inject} from './test_injector';
export function proxy() { export function proxy() {}
}
var _global: jasmine.GlobalPolluter = <any>(typeof window === 'undefined' ? global : window); var _global: jasmine.GlobalPolluter = <any>(typeof window === 'undefined' ? global : window);

View File

@ -42,7 +42,8 @@ export function el(html: string) {
return DOM.firstChild(DOM.content(DOM.createTemplate(html))); return DOM.firstChild(DOM.content(DOM.createTemplate(html)));
} }
var _RE_SPECIAL_CHARS = ['-', '[', ']', '/', '{', '}', '\\', '(', ')', '*', '+', '?', '.', '^', '$', '|']; var _RE_SPECIAL_CHARS =
['-', '[', ']', '/', '{', '}', '\\', '(', ')', '*', '+', '?', '.', '^', '$', '|'];
var _ESCAPE_RE = RegExpWrapper.create(`[\\${_RE_SPECIAL_CHARS.join('\\')}]`); var _ESCAPE_RE = RegExpWrapper.create(`[\\${_RE_SPECIAL_CHARS.join('\\')}]`);
export function containsRegexp(input: string): RegExp { export function containsRegexp(input: string): RegExp {
return RegExpWrapper.create( return RegExpWrapper.create(

View File

@ -89,9 +89,12 @@ export class TestDefinition {
*/ */
export function getAllDefinitions(): List<TestDefinition> { export function getAllDefinitions(): List<TestDefinition> {
var allDefs = _availableDefinitions; var allDefs = _availableDefinitions;
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithLocals.availableDefinitions)); allDefs = ListWrapper.concat(allDefs,
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithMode.availableDefinitions)); StringMapWrapper.keys(_ExpressionWithLocals.availableDefinitions));
allDefs = ListWrapper.concat(allDefs, StringMapWrapper.keys(_DirectiveUpdating.availableDefinitions)); allDefs =
ListWrapper.concat(allDefs, StringMapWrapper.keys(_ExpressionWithMode.availableDefinitions));
allDefs =
ListWrapper.concat(allDefs, StringMapWrapper.keys(_DirectiveUpdating.availableDefinitions));
return ListWrapper.map(allDefs, (id) => getDefinition(id)); return ListWrapper.map(allDefs, (id) => getDefinition(id));
} }

View File

@ -87,7 +87,8 @@ export function main() {
function _createWithoutHydrate(expression: string) { function _createWithoutHydrate(expression: string) {
var dispatcher = new TestDispatcher(); var dispatcher = new TestDispatcher();
var registry = null; var registry = null;
var cd = _getProtoChangeDetector(getDefinition(expression).cdDef, registry).instantiate(dispatcher); var cd = _getProtoChangeDetector(getDefinition(expression).cdDef, registry)
.instantiate(dispatcher);
return new _ChangeDetectorAndDispatcher(cd, dispatcher); return new _ChangeDetectorAndDispatcher(cd, dispatcher);
} }
@ -334,7 +335,8 @@ export function main() {
it('should happen directly, without invoking the dispatcher', () => { it('should happen directly, without invoking the dispatcher', () => {
var val = _createWithoutHydrate('directNoDispatcher'); var val = _createWithoutHydrate('directNoDispatcher');
val.changeDetector.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directive1], [])); val.changeDetector.hydrate(_DEFAULT_CONTEXT, null,
new FakeDirectives([directive1], []));
val.changeDetector.detectChanges(); val.changeDetector.detectChanges();
expect(val.dispatcher.loggedValues).toEqual([]); expect(val.dispatcher.loggedValues).toEqual([]);
expect(directive1.a).toEqual(42); expect(directive1.a).toEqual(42);
@ -465,11 +467,11 @@ export function main() {
var orderOfOperations = []; var orderOfOperations = [];
var directiveInShadowDom = null; var directiveInShadowDom = null;
directiveInShadowDom = directiveInShadowDom = new TestDirective(
new TestDirective(() => { ListWrapper.push(orderOfOperations, directiveInShadowDom); }); () => { ListWrapper.push(orderOfOperations, directiveInShadowDom); });
var parentDirective = null; var parentDirective = null;
parentDirective = parentDirective = new TestDirective(
new TestDirective(() => { ListWrapper.push(orderOfOperations, parentDirective); }); () => { ListWrapper.push(orderOfOperations, parentDirective); });
parent.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([parentDirective], [])); parent.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([parentDirective], []));
child.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directiveInShadowDom], [])); child.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directiveInShadowDom], []));
@ -594,14 +596,13 @@ export function main() {
}); });
describe('mode', () => { describe('mode', () => {
it('should set the mode to CHECK_ALWAYS when the default change detection is used', it('should set the mode to CHECK_ALWAYS when the default change detection is used', () => {
() => { var cd = _createWithoutHydrate('emptyUsingDefaultStrategy').changeDetector;
var cd = _createWithoutHydrate('emptyUsingDefaultStrategy').changeDetector; expect(cd.mode).toEqual(null);
expect(cd.mode).toEqual(null);
cd.hydrate(_DEFAULT_CONTEXT, null, null); cd.hydrate(_DEFAULT_CONTEXT, null, null);
expect(cd.mode).toEqual(CHECK_ALWAYS); expect(cd.mode).toEqual(CHECK_ALWAYS);
}); });
it('should set the mode to CHECK_ONCE when the push change detection is used', () => { it('should set the mode to CHECK_ONCE when the push change detection is used', () => {
var cd = _createWithoutHydrate('emptyUsingOnPushStrategy').changeDetector; var cd = _createWithoutHydrate('emptyUsingOnPushStrategy').changeDetector;

View File

@ -462,14 +462,14 @@ export function main() {
function exprSources(templateBindings) { function exprSources(templateBindings) {
return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ? return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ?
binding.expression.source : binding.expression.source :
null); null);
} }
function exprAsts(templateBindings) { function exprAsts(templateBindings) {
return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ? return ListWrapper.map(templateBindings, (binding) => isPresent(binding.expression) ?
binding.expression : binding.expression :
null); null);
} }
it('should parse an empty string', () => { it('should parse an empty string', () => {

View File

@ -31,9 +31,7 @@ export function main() {
function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); } function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); }
beforeEach(() => { beforeEach(() => {
inceptionObj = { inceptionObj = {dream: {dream: {dream: 'Limbo'}}};
dream: {dream: {dream: 'Limbo'}}
};
inceptionObjString = "{\n" + " \"dream\": {\n" + " \"dream\": {\n" + inceptionObjString = "{\n" + " \"dream\": {\n" + " \"dream\": {\n" +
" \"dream\": \"Limbo\"\n" + " }\n" + " }\n" + "}"; " \"dream\": \"Limbo\"\n" + " }\n" + " }\n" + "}";

View File

@ -315,9 +315,8 @@ export function main() {
var nestedProtoView = createProtoView(); var nestedProtoView = createProtoView();
var compiler = createCompiler([ var compiler = createCompiler([
createRenderProtoView([ createRenderProtoView([
createRenderViewportElementBinder( createRenderViewportElementBinder(createRenderProtoView(
createRenderProtoView([createRenderComponentElementBinder(0)], [createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
renderApi.ViewType.EMBEDDED))
]), ]),
createRenderProtoView() createRenderProtoView()
], ],

View File

@ -1488,8 +1488,7 @@ class DirectiveListeningDomEvent {
} }
var globalCounter = 0; var globalCounter = 0;
@Directive( @Directive({selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
{selector: '[listenerother]', host: {'(window:domEvent)': 'onEvent($event.type)'}})
@Injectable() @Injectable()
class DirectiveListeningDomEventOther { class DirectiveListeningDomEventOther {
eventType: string; eventType: string;

View File

@ -29,7 +29,7 @@ export function main() {
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3">' + '<needs-query text="2"><div text="3">' +
'<div text="too-deep"></div>' + '<div text="too-deep"></div>' +
'</div></needs-query>' + '</div></needs-query>' +
'<div text="4"></div>'; '<div text="4"></div>';
@ -43,36 +43,36 @@ export function main() {
})); }));
it('should contain all directives in the light dom when descendants flag is used', it('should contain all directives in the light dom when descendants flag is used',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query-desc text="2"><div text="3">' + '<needs-query-desc text="2"><div text="3">' +
'<div text="4"></div>' + '<div text="4"></div>' +
'</div></needs-query-desc>' + '</div></needs-query-desc>' +
'<div text="5"></div>'; '<div text="5"></div>';
tb.createView(MyComp, {html: template}) tb.createView(MyComp, {html: template})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('2|3|4|'); expect(view.rootNodes).toHaveText('2|3|4|');
async.done(); async.done();
}); });
})); }));
it('should contain all directives in the light dom', it('should contain all directives in the light dom',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb, async) => {
var template = '<div text="1"></div>' + var template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3"></div></needs-query>' + '<needs-query text="2"><div text="3"></div></needs-query>' +
'<div text="4"></div>'; '<div text="4"></div>';
tb.createView(MyComp, {html: template}) tb.createView(MyComp, {html: template})
.then((view) => { .then((view) => {
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('2|3|'); expect(view.rootNodes).toHaveText('2|3|');
async.done(); async.done();
}); });
})); }));
// TODO(rado): The test below should be using descendants: false, // TODO(rado): The test below should be using descendants: false,
// but due to a bug with how injectors are hooked up query considers the // but due to a bug with how injectors are hooked up query considers the
@ -142,7 +142,9 @@ class NeedsQuery {
@Injectable() @Injectable()
class NeedsQueryDesc { class NeedsQueryDesc {
query: QueryList<TextDirective>; query: QueryList<TextDirective>;
constructor(@Query(TextDirective, {descendants: true}) query: QueryList<TextDirective>) { this.query = query; } constructor(@Query(TextDirective, {descendants: true}) query: QueryList<TextDirective>) {
this.query = query;
}
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp'})

View File

@ -14,7 +14,7 @@ import {
SpyObject, SpyObject,
inject, inject,
proxy proxy
} from 'angular2/test_lib'; } from 'angular2/test_lib';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
import {ChangeDetector} from 'angular2/change_detection'; import {ChangeDetector} from 'angular2/change_detection';
import {IMPLEMENTS} from 'angular2/src/facade/lang'; import {IMPLEMENTS} from 'angular2/src/facade/lang';

View File

@ -205,21 +205,15 @@ function commonTests() {
_zone.initCallbacks({ _zone.initCallbacks({
onTurnDone: () => { onTurnDone: () => {
_log.add('onTurnDone:started'); _log.add('onTurnDone:started');
_zone.run(() => _log.add('nested run')) _zone.run(() => _log.add('nested run')) _log.add('onTurnDone:finished');
_log.add('onTurnDone:finished');
} }
}); });
macroTask(() => { macroTask(() => { _zone.run(() => { _log.add('start run'); }); });
_zone.run(() => {
_log.add('start run');
});
});
macroTask(() => { macroTask(() => {
expect(_log.result()) expect(_log.result())
.toEqual( .toEqual('start run; onTurnDone:started; nested run; onTurnDone:finished');
'start run; onTurnDone:started; nested run; onTurnDone:finished');
async.done(); async.done();
}, 50); }, 50);
})); }));

View File

@ -92,10 +92,7 @@ export function main() {
view.detectChanges(); view.detectChanges();
expect(view.rootNodes[0].className).toEqual('ng-binding foo'); expect(view.rootNodes[0].className).toEqual('ng-binding foo');
view.context.expr = { view.context.expr = {'foo': false, 'bar': true};
'foo': false,
'bar': true
};
view.detectChanges(); view.detectChanges();
expect(view.rootNodes[0].className).toEqual('ng-binding bar'); expect(view.rootNodes[0].className).toEqual('ng-binding bar');

View File

@ -39,14 +39,15 @@ export function main() {
var baseResponse; var baseResponse;
var sampleObserver; var sampleObserver;
beforeEach(() => { beforeEach(() => {
injector = Injector.resolveAndCreate([MockBackend, bind(Http).toFactory(HttpFactory, [MockBackend])]); injector = Injector.resolveAndCreate(
[MockBackend, bind(Http).toFactory(HttpFactory, [MockBackend])]);
http = injector.get(Http); http = injector.get(Http);
backend = injector.get(MockBackend); backend = injector.get(MockBackend);
baseResponse = new Response('base response'); baseResponse = new Response('base response');
sampleObserver = new SpyObserver(); sampleObserver = new SpyObserver();
}); });
afterEach(() => { /*backend.verifyNoPendingRequests();*/ }); afterEach(() => {/*backend.verifyNoPendingRequests();*/});
it('should return an Observable', () => { it('should return an Observable', () => {

View File

@ -84,10 +84,8 @@ export function main() {
// clang-format on // clang-format on
}); });
it("should throw when more than 20 arguments", () => { it("should throw when more than 20 arguments",
expect(() => reflector.factory(TestObjWith21Args)) () => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
.toThrowError();
});
it("should return a registered factory if available", () => { it("should return a registered factory if available", () => {
reflector.registerType(TestObj, {"factory": () => "fake"}); reflector.registerType(TestObj, {"factory": () => "fake"});
@ -195,65 +193,47 @@ export function main() {
class TestObjWith00Args { class TestObjWith00Args {
args: List<any>; args: List<any>;
constructor() { constructor() { this.args = []; }
this.args = [];
}
} }
class TestObjWith01Args { class TestObjWith01Args {
args: List<any>; args: List<any>;
constructor(a1) { constructor(a1) { this.args = [a1]; }
this.args = [a1];
}
} }
class TestObjWith02Args { class TestObjWith02Args {
args: List<any>; args: List<any>;
constructor(a1, a2) { constructor(a1, a2) { this.args = [a1, a2]; }
this.args = [a1, a2];
}
} }
class TestObjWith03Args { class TestObjWith03Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3) { constructor(a1, a2, a3) { this.args = [a1, a2, a3]; }
this.args = [a1, a2, a3];
}
} }
class TestObjWith04Args { class TestObjWith04Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4) { constructor(a1, a2, a3, a4) { this.args = [a1, a2, a3, a4]; }
this.args = [a1, a2, a3, a4];
}
} }
class TestObjWith05Args { class TestObjWith05Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5) { constructor(a1, a2, a3, a4, a5) { this.args = [a1, a2, a3, a4, a5]; }
this.args = [a1, a2, a3, a4, a5];
}
} }
class TestObjWith06Args { class TestObjWith06Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6) { constructor(a1, a2, a3, a4, a5, a6) { this.args = [a1, a2, a3, a4, a5, a6]; }
this.args = [a1, a2, a3, a4, a5, a6];
}
} }
class TestObjWith07Args { class TestObjWith07Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7) { constructor(a1, a2, a3, a4, a5, a6, a7) { this.args = [a1, a2, a3, a4, a5, a6, a7]; }
this.args = [a1, a2, a3, a4, a5, a6, a7];
}
} }
class TestObjWith08Args { class TestObjWith08Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8) { constructor(a1, a2, a3, a4, a5, a6, a7, a8) { this.args = [a1, a2, a3, a4, a5, a6, a7, a8]; }
this.args = [a1, a2, a3, a4, a5, a6, a7, a8];
}
} }
class TestObjWith09Args { class TestObjWith09Args {
@ -328,21 +308,48 @@ class TestObjWith18Args {
class TestObjWith19Args { class TestObjWith19Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) { constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]; a19) {
this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19];
} }
} }
class TestObjWith20Args { class TestObjWith20Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) { constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]; a20) {
this.args =
[a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20];
} }
} }
class TestObjWith21Args { class TestObjWith21Args {
args: List<any>; args: List<any>;
constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) { constructor(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
this.args = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21]; a20, a21) {
this.args = [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19,
a20,
a21
];
} }
} }

View File

@ -244,7 +244,7 @@ var someDirectiveWithProps = DirectiveMetadata.create({
var someDirectiveWithHostProperties = DirectiveMetadata.create({ var someDirectiveWithHostProperties = DirectiveMetadata.create({
selector: '[some-decor-with-host-props]', selector: '[some-decor-with-host-props]',
host: MapWrapper.createFromStringMap({'[hostProp]' : 'dirProp'}) host: MapWrapper.createFromStringMap({'[hostProp]': 'dirProp'})
}); });
var someDirectiveWithHostAttributes = DirectiveMetadata.create({ var someDirectiveWithHostAttributes = DirectiveMetadata.create({
@ -252,10 +252,8 @@ var someDirectiveWithHostAttributes = DirectiveMetadata.create({
host: MapWrapper.createFromStringMap({'attr_name': 'attr_val', 'class': 'foo bar'}) host: MapWrapper.createFromStringMap({'attr_name': 'attr_val', 'class': 'foo bar'})
}); });
var someDirectiveWithEvents = DirectiveMetadata.create({ var someDirectiveWithEvents = DirectiveMetadata.create(
selector: '[some-decor-events]', {selector: '[some-decor-events]', host: MapWrapper.createFromStringMap({'(click)': 'doIt()'})});
host: MapWrapper.createFromStringMap({'(click)': 'doIt()'})
});
var someDirectiveWithHostActions = DirectiveMetadata.create({ var someDirectiveWithHostActions = DirectiveMetadata.create({
selector: '[some-decor-host-actions]', selector: '[some-decor-host-actions]',

View File

@ -42,8 +42,7 @@ export function main() {
var pipeline = new CompilePipeline([ var pipeline = new CompilePipeline([
new MockStep((parent, current, control) => { new MockStep((parent, current, control) => {
if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) { if (isPresent(DOM.getAttribute(current.element, 'viewroot'))) {
current.inheritedProtoView = current.inheritedProtoView = new ProtoViewBuilder(current.element, ViewType.EMBEDDED);
new ProtoViewBuilder(current.element, ViewType.EMBEDDED);
} }
}) })
]); ]);

View File

@ -26,10 +26,14 @@ export function main() {
}); });
var map = directiveMetadataToMap(someComponent); var map = directiveMetadataToMap(someComponent);
expect(MapWrapper.get(map, 'compileChildren')).toEqual(false); expect(MapWrapper.get(map, 'compileChildren')).toEqual(false);
expect(MapWrapper.get(map, 'hostListeners')).toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']])); expect(MapWrapper.get(map, 'hostListeners'))
expect(MapWrapper.get(map, 'hostProperties')).toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']])); .toEqual(MapWrapper.createFromPairs([['LKey', 'LVal']]));
expect(MapWrapper.get(map, 'hostActions')).toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']])); expect(MapWrapper.get(map, 'hostProperties'))
expect(MapWrapper.get(map, 'hostAttributes')).toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']])); .toEqual(MapWrapper.createFromPairs([['PKey', 'PVal']]));
expect(MapWrapper.get(map, 'hostActions'))
.toEqual(MapWrapper.createFromPairs([['AcKey', 'AcVal']]));
expect(MapWrapper.get(map, 'hostAttributes'))
.toEqual(MapWrapper.createFromPairs([['AtKey', 'AtVal']]));
expect(MapWrapper.get(map, 'id')).toEqual('someComponent'); expect(MapWrapper.get(map, 'id')).toEqual('someComponent');
expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']); expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']);
expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']); expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']);

View File

@ -75,8 +75,9 @@ export function main() {
tb.compileAll([ tb.compileAll([
someComponent, someComponent,
new ViewDefinition({ new ViewDefinition({
componentId: 'someComponent', template: '<some-comp> <!-- comment -->\n </some-comp>', componentId: 'someComponent',
directives: [someComponent] template: '<some-comp> <!-- comment -->\n </some-comp>',
directives: [someComponent]
}) })
]) ])
.then((protoViewDtos) => { .then((protoViewDtos) => {

View File

@ -97,19 +97,21 @@ export function main() {
expect(DOM.getText(styleElement)).not.toEqual(DOM.getText(styleElement2)); expect(DOM.getText(styleElement)).not.toEqual(DOM.getText(styleElement2));
}); });
it('should move the style element to the style host when @imports are present', inject([AsyncTestCompleter], (async) => { it('should move the style element to the style host when @imports are present',
xhr.reply('http://base/one.css', '.one {}'); inject([AsyncTestCompleter], (async) => {
xhr.reply('http://base/one.css', '.one {}');
var compileElement = el('<div><style>@import "one.css";</style></div>'); var compileElement = el('<div><style>@import "one.css";</style></div>');
var styleElement = DOM.firstChild(compileElement); var styleElement = DOM.firstChild(compileElement);
var stylePromise = strategy.processStyleElement('someComponent', 'http://base', styleElement); var stylePromise =
strategy.processStyleElement('someComponent', 'http://base', styleElement);
stylePromise.then((_) => { stylePromise.then((_) => {
expect(compileElement).toHaveText(''); expect(compileElement).toHaveText('');
expect(styleHost).toHaveText('.one[_ngcontent-0] {\n\n}'); expect(styleHost).toHaveText('.one[_ngcontent-0] {\n\n}');
async.done(); async.done();
}); });
})); }));
it('should move the style element to the style host', () => { it('should move the style element to the style host', () => {
var compileElement = el('<div><style>.one {}</style></div>'); var compileElement = el('<div><style>.one {}</style></div>');

View File

@ -43,8 +43,8 @@ export function main() {
styleInliner, styleUrlResolver, null), styleInliner, styleUrlResolver, null),
[StyleInliner, StyleUrlResolver]), [StyleInliner, StyleUrlResolver]),
"unscoped": bind(ShadowDomStrategy) "unscoped": bind(ShadowDomStrategy)
.toFactory((styleUrlResolver) => new EmulatedUnscopedShadowDomStrategy( .toFactory((styleUrlResolver) =>
styleUrlResolver, null), new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, null),
[StyleUrlResolver]) [StyleUrlResolver])
}; };
if (DOM.supportsNativeShadowDOM()) { if (DOM.supportsNativeShadowDOM()) {
@ -398,14 +398,14 @@ export function main() {
} }
var mainDir = var mainDir = DirectiveMetadata.create(
DirectiveMetadata.create({selector: 'main', id: 'main', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'main', id: 'main', type: DirectiveMetadata.COMPONENT_TYPE});
var simple = DirectiveMetadata.create( var simple = DirectiveMetadata.create(
{selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE});
var empty = var empty = DirectiveMetadata.create(
DirectiveMetadata.create({selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
var dynamicComponent = DirectiveMetadata.create( var dynamicComponent = DirectiveMetadata.create(
{selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE});
@ -425,11 +425,11 @@ var outerWithIndirectNestedComponent = DirectiveMetadata.create({
type: DirectiveMetadata.COMPONENT_TYPE type: DirectiveMetadata.COMPONENT_TYPE
}); });
var outerComponent = var outerComponent = DirectiveMetadata.create(
DirectiveMetadata.create({selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
var innerComponent = var innerComponent = DirectiveMetadata.create(
DirectiveMetadata.create({selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
var innerInnerComponent = DirectiveMetadata.create( var innerInnerComponent = DirectiveMetadata.create(
{selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE});

View File

@ -33,32 +33,35 @@ export function main() {
}); });
if (!IS_DARTIUM) { if (!IS_DARTIUM) {
it('should use a noop setter if the property did not exist when the setter was created', () => { it('should use a noop setter if the property did not exist when the setter was created',
var setterFn = setterFactory.createSetter(div, false, 'someProp'); () => {
div.someProp = ''; var setterFn = setterFactory.createSetter(div, false, 'someProp');
setterFn(div, 'Hello'); div.someProp = '';
expect(div.someProp).toEqual(''); setterFn(div, 'Hello');
}); expect(div.someProp).toEqual('');
});
it('should use a noop setter if the property did not exist when the setter was created for ng components', () => { it('should use a noop setter if the property did not exist when the setter was created for ng components',
var ce = el('<some-ce></some-ce>'); () => {
var setterFn = setterFactory.createSetter(ce, true, 'someProp'); var ce = el('<some-ce></some-ce>');
ce.someProp = ''; var setterFn = setterFactory.createSetter(ce, true, 'someProp');
setterFn(ce, 'Hello'); ce.someProp = '';
expect(ce.someProp).toEqual(''); setterFn(ce, 'Hello');
}); expect(ce.someProp).toEqual('');
});
it('should set the property for custom elements even if it was not present when the setter was created', () => { it('should set the property for custom elements even if it was not present when the setter was created',
var ce = el('<some-ce></some-ce>'); () => {
var setterFn = setterFactory.createSetter(ce, false, 'someProp'); var ce = el('<some-ce></some-ce>');
ce.someProp = ''; var setterFn = setterFactory.createSetter(ce, false, 'someProp');
// Our CJS DOM adapter does not support custom properties, ce.someProp = '';
// need to exclude here. // Our CJS DOM adapter does not support custom properties,
if (DOM.hasProperty(ce, 'someProp')) { // need to exclude here.
setterFn(ce, 'Hello'); if (DOM.hasProperty(ce, 'someProp')) {
expect(ce.someProp).toEqual('Hello'); setterFn(ce, 'Hello');
} expect(ce.someProp).toEqual('Hello');
}); }
});
} }
}); });

View File

@ -48,25 +48,22 @@ export function main() {
return new DomView(pv, [DOM.childNodes(root)[0]], [], boundElements); return new DomView(pv, [DOM.childNodes(root)[0]], [], boundElements);
} }
function createElementBinder(parentIndex:number = 0, distanceToParent:number = 1) { function createElementBinder(parentIndex: number = 0, distanceToParent: number = 1) {
return new ElementBinder({parentIndex: parentIndex, distanceToParent:distanceToParent, textNodeIndices:[]}); return new ElementBinder(
{parentIndex: parentIndex, distanceToParent: distanceToParent, textNodeIndices: []});
} }
describe('getDirectParentElement', () => { describe('getDirectParentElement', () => {
it('should return the DomElement of the direct parent', () => { it('should return the DomElement of the direct parent', () => {
var pv = createProtoView( var pv = createProtoView([createElementBinder(), createElementBinder(0, 1)]);
[createElementBinder(), createElementBinder(0, 1)]);
var view = createView(pv, 2); var view = createView(pv, 2);
expect(view.getDirectParentElement(1)).toBe(view.boundElements[0]); expect(view.getDirectParentElement(1)).toBe(view.boundElements[0]);
}); });
it('should return null if the direct parent is not bound', () => { it('should return null if the direct parent is not bound', () => {
var pv = createProtoView([ var pv = createProtoView(
createElementBinder(), [createElementBinder(), createElementBinder(), createElementBinder(0, 2)]);
createElementBinder(),
createElementBinder(0,2)
]);
var view = createView(pv, 3); var view = createView(pv, 3);
expect(view.getDirectParentElement(2)).toBe(null); expect(view.getDirectParentElement(2)).toBe(null);
}); });

View File

@ -22,103 +22,122 @@ export function main() {
beforeEach(() => { registry = new RouteRegistry(); }); beforeEach(() => { registry = new RouteRegistry(); });
it('should match the full URL', inject([AsyncTestCompleter], (async) => { it('should match the full URL', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/', 'component': DummyCompA}); registry.config(rootHostComponent, {'path': '/', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/test', 'component': DummyCompB}); registry.config(rootHostComponent, {'path': '/test', 'component': DummyCompB});
registry.recognize('/test', rootHostComponent).then((instruction) => { registry.recognize('/test', rootHostComponent)
expect(instruction.component).toBe(DummyCompB); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompB);
}); async.done();
})); });
}));
it('should prefer static segments to dynamic', inject([AsyncTestCompleter], (async) => { it('should prefer static segments to dynamic', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompB}); registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompB});
registry.config(rootHostComponent, {'path': '/home', 'component': DummyCompA}); registry.config(rootHostComponent, {'path': '/home', 'component': DummyCompA});
registry.recognize('/home', rootHostComponent).then((instruction) => { registry.recognize('/home', rootHostComponent)
expect(instruction.component).toBe(DummyCompA); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompA);
}); async.done();
})); });
}));
it('should prefer dynamic segments to star', inject([AsyncTestCompleter], (async) => { it('should prefer dynamic segments to star', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompA}); registry.config(rootHostComponent, {'path': '/:site', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/*site', 'component': DummyCompB}); registry.config(rootHostComponent, {'path': '/*site', 'component': DummyCompB});
registry.recognize('/home', rootHostComponent).then((instruction) => { registry.recognize('/home', rootHostComponent)
expect(instruction.component).toBe(DummyCompA); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompA);
}); async.done();
})); });
}));
it('should prefer routes with more dynamic segments', inject([AsyncTestCompleter], (async) => { it('should prefer routes with more dynamic segments', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/:first/*rest', 'component': DummyCompA}); registry.config(rootHostComponent, {'path': '/:first/*rest', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/*all', 'component': DummyCompB}); registry.config(rootHostComponent, {'path': '/*all', 'component': DummyCompB});
registry.recognize('/some/path', rootHostComponent).then((instruction) => { registry.recognize('/some/path', rootHostComponent)
expect(instruction.component).toBe(DummyCompA); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompA);
}); async.done();
})); });
}));
it('should prefer routes with more static segments', inject([AsyncTestCompleter], (async) => { it('should prefer routes with more static segments', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first/:second', 'component': DummyCompA}); registry.config(rootHostComponent, {'path': '/first/:second', 'component': DummyCompA});
registry.config(rootHostComponent, {'path': '/:first/:second', 'component': DummyCompB}); registry.config(rootHostComponent, {'path': '/:first/:second', 'component': DummyCompB});
registry.recognize('/first/second', rootHostComponent).then((instruction) => { registry.recognize('/first/second', rootHostComponent)
expect(instruction.component).toBe(DummyCompA); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompA);
}); async.done();
})); });
}));
it('should prefer routes with static segments before dynamic segments', inject([AsyncTestCompleter], (async) => { it('should prefer routes with static segments before dynamic segments',
registry.config(rootHostComponent, {'path': '/first/second/:third', 'component': DummyCompB}); inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first/:second/third', 'component': DummyCompA}); registry.config(rootHostComponent,
{'path': '/first/second/:third', 'component': DummyCompB});
registry.config(rootHostComponent,
{'path': '/first/:second/third', 'component': DummyCompA});
registry.recognize('/first/second/third', rootHostComponent).then((instruction) => { registry.recognize('/first/second/third', rootHostComponent)
expect(instruction.component).toBe(DummyCompB); .then((instruction) => {
async.done(); expect(instruction.component).toBe(DummyCompB);
}); async.done();
})); });
}));
it('should match the full URL using child components', inject([AsyncTestCompleter], (async) => { it('should match the full URL using child components', inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first', 'component': DummyParentComp}); registry.config(rootHostComponent, {'path': '/first', 'component': DummyParentComp});
registry.recognize('/first/second', rootHostComponent).then((instruction) => { registry.recognize('/first/second', rootHostComponent)
expect(instruction.component).toBe(DummyParentComp); .then((instruction) => {
expect(instruction.child.component).toBe(DummyCompB); expect(instruction.component).toBe(DummyParentComp);
async.done(); expect(instruction.child.component).toBe(DummyCompB);
}); async.done();
})); });
}));
it('should match the URL using async child components', inject([AsyncTestCompleter], (async) => { it('should match the URL using async child components',
registry.config(rootHostComponent, {'path': '/first', 'component': DummyAsyncComp}); inject([AsyncTestCompleter], (async) => {
registry.config(rootHostComponent, {'path': '/first', 'component': DummyAsyncComp});
registry.recognize('/first/second', rootHostComponent).then((instruction) => { registry.recognize('/first/second', rootHostComponent)
expect(instruction.component).toBe(DummyAsyncComp); .then((instruction) => {
expect(instruction.child.component).toBe(DummyCompB); expect(instruction.component).toBe(DummyAsyncComp);
async.done(); expect(instruction.child.component).toBe(DummyCompB);
}); async.done();
})); });
}));
it('should match the URL using an async parent component', inject([AsyncTestCompleter], (async) => { it('should match the URL using an async parent component',
registry.config(rootHostComponent, {'path': '/first', 'component': {'loader': AsyncParentLoader, 'type': 'loader'} }); inject([AsyncTestCompleter], (async) => {
registry.config(
rootHostComponent,
{'path': '/first', 'component': {'loader': AsyncParentLoader, 'type': 'loader'}});
registry.recognize('/first/second', rootHostComponent).then((instruction) => { registry.recognize('/first/second', rootHostComponent)
expect(instruction.component).toBe(DummyParentComp); .then((instruction) => {
expect(instruction.child.component).toBe(DummyCompB); expect(instruction.component).toBe(DummyParentComp);
async.done(); expect(instruction.child.component).toBe(DummyCompB);
}); async.done();
})); });
}));
it('should throw when a config does not have a component or redirectTo property', () => { it('should throw when a config does not have a component or redirectTo property', () => {
expect(() => registry.config(rootHostComponent, {'path': '/some/path' })) expect(() => registry.config(rootHostComponent, {'path': '/some/path'}))
.toThrowError('Route config should contain exactly one \'component\', or \'redirectTo\' property'); .toThrowError(
'Route config should contain exactly one \'component\', or \'redirectTo\' property');
}); });
it('should throw when a config has an invalid component type', () => { it('should throw when a config has an invalid component type', () => {
expect(() => registry.config(rootHostComponent, {'path': '/some/path', 'component': { 'type': 'intentionallyWrongComponentType' } })) expect(() => registry.config(
.toThrowError('Invalid component type \'intentionallyWrongComponentType\''); rootHostComponent,
{'path': '/some/path', 'component': {'type': 'intentionallyWrongComponentType'}}))
.toThrowError('Invalid component type \'intentionallyWrongComponentType\'');
}); });
}); });
} }
@ -131,10 +150,9 @@ function AsyncChildLoader() {
return PromiseWrapper.resolve(DummyCompB); return PromiseWrapper.resolve(DummyCompB);
} }
@RouteConfig([ @RouteConfig([{'path': '/second', 'component': {'loader': AsyncChildLoader, 'type': 'loader'}}])
{ 'path': '/second', 'component': { 'loader': AsyncChildLoader, 'type': 'loader' } } class DummyAsyncComp {
]) }
class DummyAsyncComp {}
class DummyCompA {} class DummyCompA {}
class DummyCompB {} class DummyCompB {}

View File

@ -49,12 +49,7 @@ angular.module('app', [])
for (var i = 0; i < totalRows; i++) { for (var i = 0; i < totalRows; i++) {
data[i] = []; data[i] = [];
for (var j = 0; j < totalColumns; j++) { for (var j = 0; j < totalColumns; j++) {
data[i][j] = { data[i][j] = {i: i, j: j, iFn: iGetter, jFn: jGetter};
i: i,
j: j,
iFn: iGetter,
jFn: jGetter
};
} }
} }
}) })

View File

@ -242,7 +242,7 @@ var _SET_TIMEOUT = new OpaqueToken('PerflogMetric.setTimeout');
var _BINDINGS = [ var _BINDINGS = [
bind(PerflogMetric) bind(PerflogMetric)
.toFactory((driverExtension, setTimeout, microMetrics, forceGc) => .toFactory((driverExtension, setTimeout, microMetrics, forceGc) =>
new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc), new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc),
[WebDriverExtension, _SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC]), [WebDriverExtension, _SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC]),
bind(_SET_TIMEOUT).toValue((fn, millis) => TimerWrapper.setTimeout(fn, millis)) bind(_SET_TIMEOUT).toValue((fn, millis) => TimerWrapper.setTimeout(fn, millis))
]; ];

View File

@ -100,7 +100,7 @@ var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
var _BINDINGS = [ var _BINDINGS = [
bind(ConsoleReporter) bind(ConsoleReporter)
.toFactory((columnWidth, sampleDescription, print) => .toFactory((columnWidth, sampleDescription, print) =>
new ConsoleReporter(columnWidth, sampleDescription, print), new ConsoleReporter(columnWidth, sampleDescription, print),
[_COLUMN_WIDTH, SampleDescription, _PRINT]), [_COLUMN_WIDTH, SampleDescription, _PRINT]),
bind(_COLUMN_WIDTH).toValue(18), bind(_COLUMN_WIDTH).toValue(18),
bind(_PRINT).toValue(print) bind(_PRINT).toValue(print)

View File

@ -52,7 +52,7 @@ var _PATH = new OpaqueToken('JsonFileReporter.path');
var _BINDINGS = [ var _BINDINGS = [
bind(JsonFileReporter) bind(JsonFileReporter)
.toFactory((sampleDescription, path, writeFile, now) => .toFactory((sampleDescription, path, writeFile, now) =>
new JsonFileReporter(sampleDescription, path, writeFile, now), new JsonFileReporter(sampleDescription, path, writeFile, now),
[SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]), [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
bind(_PATH).toValue('.') bind(_PATH).toValue('.')
]; ];

View File

@ -26,13 +26,13 @@ export class SampleDescription {
var _BINDINGS = [ var _BINDINGS = [
bind(SampleDescription) bind(SampleDescription)
.toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) => .toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
new SampleDescription(id, [ new SampleDescription(id, [
{'forceGc': forceGc, 'userAgent': userAgent}, {'forceGc': forceGc, 'userAgent': userAgent},
validator.describe(), validator.describe(),
defaultDesc, defaultDesc,
userDesc userDesc
], ],
metric.describe()), metric.describe()),
[ [
Metric, Metric,
Options.SAMPLE_ID, Options.SAMPLE_ID,

View File

@ -72,9 +72,7 @@ class MockMetric extends Metric {
endMeasure(restart: boolean): Promise<StringMap<string, any>> { endMeasure(restart: boolean): Promise<StringMap<string, any>> {
var result = {}; var result = {};
result[this._id] = { result[this._id] = {'restart': restart};
'restart': restart
};
return PromiseWrapper.resolve(result); return PromiseWrapper.resolve(result);
} }

View File

@ -18,9 +18,8 @@ export function main() {
var reporter; var reporter;
var log; var log;
function createReporter({columnWidth = null, sampleId = null, descriptions = null, metrics = null}:{ function createReporter({columnWidth = null, sampleId = null, descriptions = null,
columnWidth?, sampleId?, descriptions?, metrics? metrics = null}: {columnWidth?, sampleId?, descriptions?, metrics?}) {
}) {
log = []; log = [];
if (isBlank(descriptions)) { if (isBlank(descriptions)) {
descriptions = []; descriptions = [];

View File

@ -31,10 +31,7 @@ export function main() {
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)), bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)),
bind(Options.WRITE_FILE) bind(Options.WRITE_FILE)
.toValue((filename, content) => { .toValue((filename, content) => {
loggedFile = { loggedFile = {'filename': filename, 'content': content};
'filename': filename,
'content': content
};
return PromiseWrapper.resolve(null); return PromiseWrapper.resolve(null);
}) })
]; ];

View File

@ -34,8 +34,7 @@ if (typeof _global['$traceurRuntime'] === 'object') {
} }
Object.keys(primitives).forEach(function(name) { primitives[name].__assertName = name; }); Object.keys(primitives).forEach(function(name) { primitives[name].__assertName = name; });
export function proxy() { export function proxy() {}
}
function assertArgumentTypes(...params) { function assertArgumentTypes(...params) {
var actual, type; var actual, type;

View File

@ -9,9 +9,7 @@ import {DiffingFlatten} from './broccoli-flatten';
describe('Flatten', () => { describe('Flatten', () => {
afterEach(() => mockfs.restore()); afterEach(() => mockfs.restore());
function flatten(inputPaths) { function flatten(inputPaths) { return new DiffingFlatten(inputPaths, 'output', null); }
return new DiffingFlatten(inputPaths, 'output', null);
}
function read(path) { return fs.readFileSync(path, {encoding: "utf-8"}); } function read(path) { return fs.readFileSync(path, {encoding: "utf-8"}); }
function rm(path) { return fs.unlinkSync(path); } function rm(path) { return fs.unlinkSync(path); }
@ -40,7 +38,7 @@ describe('Flatten', () => {
expect(fs.readdirSync('output')).toEqual(['file-1.1.txt', 'file-1.txt', 'file-2.txt']); expect(fs.readdirSync('output')).toEqual(['file-1.1.txt', 'file-1.txt', 'file-2.txt']);
// fails due to a mock-fs bug related to reading symlinks? // fails due to a mock-fs bug related to reading symlinks?
//expect(read('output/file-1.1.txt')).toBe('file-1.1.txt content'); // expect(read('output/file-1.1.txt')).toBe('file-1.1.txt content');
// delete a file // delete a file
@ -59,9 +57,8 @@ describe('Flatten', () => {
'input': { 'input': {
'dir1': { 'dir1': {
'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}), 'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
'subdir-1': { 'subdir-1':
'file-1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)}) {'file-1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})},
},
'empty-dir': {} 'empty-dir': {}
}, },
}, },
@ -71,7 +68,7 @@ describe('Flatten', () => {
let differ = new TreeDiffer('testLabel', 'input'); let differ = new TreeDiffer('testLabel', 'input');
let flattenedTree = flatten('input'); let flattenedTree = flatten('input');
expect(() => flattenedTree.rebuild(differ.diffTree())). expect(() => flattenedTree.rebuild(differ.diffTree()))
toThrowError("Duplicate file 'file-1.txt' found in path 'dir1/subdir-1/file-1.txt'"); .toThrowError("Duplicate file 'file-1.txt' found in path 'dir1/subdir-1/file-1.txt'");
}); });
}); });

View File

@ -11,7 +11,11 @@ interface LodashRendererOptions {
files?: string[]; files?: string[];
} }
const kDefaultOptions: LodashRendererOptions = {encoding: 'utf-8', context: {}, files: []}; const kDefaultOptions: LodashRendererOptions = {
encoding: 'utf-8',
context: {},
files: []
};
/** /**

View File

@ -54,8 +54,8 @@ describe('MergeTrees', () => {
mockfs(testDir); mockfs(testDir);
let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']); let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']);
let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {}); let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {});
expect(() => treeMerger.rebuild(treeDiffer.diffTrees())). expect(() => treeMerger.rebuild(treeDiffer.diffTrees()))
toThrowError("`overwrite` option is required for handling duplicates."); .toThrowError("`overwrite` option is required for handling duplicates.");
testDir = { testDir = {
'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})}, 'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})},
@ -81,7 +81,7 @@ describe('MergeTrees', () => {
testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)}); testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)});
mockfs(testDir); mockfs(testDir);
expect(() => treeMerger.rebuild(treeDiffer.diffTrees())). expect(() => treeMerger.rebuild(treeDiffer.diffTrees()))
toThrowError("`overwrite` option is required for handling duplicates."); .toThrowError("`overwrite` option is required for handling duplicates.");
}); });
}); });

View File

@ -10,7 +10,9 @@ import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-br
type FileRegistry = ts.Map<{version: number}>; type FileRegistry = ts.Map<{version: number}>;
const FS_OPTS = {encoding: 'utf-8'}; const FS_OPTS = {
encoding: 'utf-8'
};
/** /**

View File

@ -34,7 +34,7 @@ export interface DiffingBroccoliPlugin {
type DiffingPluginWrapperFactory = (inputTrees: (BroccoliTree | BroccoliTree[]), options?) => type DiffingPluginWrapperFactory = (inputTrees: (BroccoliTree | BroccoliTree[]), options?) =>
BroccoliTree; BroccoliTree;
class DiffingPluginWrapper implements BroccoliTree { class DiffingPluginWrapper implements BroccoliTree {

View File

@ -30,8 +30,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree(); let diffResult = differ.diffTree();
expect(diffResult.addedPaths) expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
expect(diffResult.changedPaths).toEqual([]); expect(diffResult.changedPaths).toEqual([]);
expect(diffResult.removedPaths).toEqual([]); expect(diffResult.removedPaths).toEqual([]);
@ -83,8 +82,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree(); let diffResult = differ.diffTree();
expect(diffResult.addedPaths) expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
// change two files // change two files
testDir['dir1']['file-1.txt'] = mockfs.file({content: 'new content', mtime: new Date(1000)}); testDir['dir1']['file-1.txt'] = mockfs.file({content: 'new content', mtime: new Date(1000)});
@ -129,8 +127,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree(); let diffResult = differ.diffTree();
expect(diffResult.addedPaths) expect(diffResult.addedPaths).toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
.toEqual(['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt']);
// change two files // change two files
testDir['orig_path']['file-1.txt'] = testDir['orig_path']['file-1.txt'] =
@ -257,8 +254,7 @@ describe('TreeDiffer', () => {
let diffResult = differ.diffTree(); let diffResult = differ.diffTree();
expect(diffResult.addedPaths) expect(diffResult.addedPaths).toEqual(['file-1.cs', 'file-1.ts', 'file-1d.cs', 'file-3.ts']);
.toEqual(['file-1.cs', 'file-1.ts', 'file-1d.cs', 'file-3.ts']);
// change two files // change two files
testDir['dir1']['file-1.ts'] = mockfs.file({content: 'new content', mtime: new Date(1000)}); testDir['dir1']['file-1.ts'] = mockfs.file({content: 'new content', mtime: new Date(1000)});

View File

@ -133,10 +133,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
// Get scripts for each benchmark or example // Get scripts for each benchmark or example
let servingTrees = kServedPaths.reduce(getServedFunnels, []); let servingTrees = kServedPaths.reduce(getServedFunnels, []);
function getServedFunnels(funnels, destDir) { function getServedFunnels(funnels, destDir) {
let options = { let options = {srcDir: '/', destDir: destDir};
srcDir: '/',
destDir: destDir
};
funnels.push(new Funnel(vendorScriptsTree, options)); funnels.push(new Funnel(vendorScriptsTree, options));
if (destDir.indexOf('benchmarks') > -1) { if (destDir.indexOf('benchmarks') > -1) {
funnels.push(new Funnel(vendorScripts_benchmark, options)); funnels.push(new Funnel(vendorScripts_benchmark, options));