chore: move to clang-format 1.0.17.

clang-format 1.0.17 substantially improves formatting for fat arrow functions
and array literal detection. It also fixes a number of minor formatting issues.
This commit is contained in:
Martin Probst 2015-06-03 13:42:57 -07:00
parent f74d7727ca
commit f999d5a156
56 changed files with 494 additions and 525 deletions

View File

@ -223,11 +223,7 @@ gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
// formatting // formatting
function doCheckFormat() { function doCheckFormat() {
return gulp.src(['Brocfile*.js', 'modules/**/*.ts', 'tools/**/*.ts', '!**/typings/**/*.d.ts', return gulp.src(['Brocfile*.js', 'modules/**/*.ts', 'tools/**/*.ts', '!**/typings/**/*.d.ts'])
// skipped due to https://github.com/angular/clang-format/issues/4
'!tools/broccoli/tree-differ.ts',
// skipped due to https://github.com/angular/gulp-clang-format/issues/3
'!tools/broccoli/broccoli-typescript.ts' ])
.pipe(format.checkFormat('file')); .pipe(format.checkFormat('file'));
} }

View File

@ -35,7 +35,8 @@ export var routerInjectables: List<any> = [
Pipeline, Pipeline,
BrowserLocation, BrowserLocation,
Location, Location,
bind(Router).toFactory((registry, pipeline, location, appRoot) => bind(Router)
{ return new RootRouter(registry, pipeline, location, appRoot);}, .toFactory((registry, pipeline, location,
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
[RouteRegistry, Pipeline, Location, appComponentTypeToken]) [RouteRegistry, Pipeline, Location, appComponentTypeToken])
]; ];

View File

@ -33,8 +33,8 @@ export var iterableDiff: List<PipeFactory> = [new IterableChangesFactory(), new
* *
* @exportedAs angular2/pipes * @exportedAs angular2/pipes
*/ */
export var async: List< export var async: List<PipeFactory> =
PipeFactory> = [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()]; [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()];
/** /**
* Uppercase text transform. * Uppercase text transform.

View File

@ -71,8 +71,8 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
.toValue(DOM.defaultDoc()), .toValue(DOM.defaultDoc()),
bind(appComponentTypeToken).toValue(appComponentType), bind(appComponentTypeToken).toValue(appComponentType),
bind(appComponentRefToken) bind(appComponentRefToken)
.toAsyncFactory((dynamicComponentLoader, injector, testability, registry) => .toAsyncFactory(
{ (dynamicComponentLoader, injector, testability, registry) => {
// TODO(rado): investigate whether to support bindings on root component. // TODO(rado): investigate whether to support bindings on root component.
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector) return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
@ -93,8 +93,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
[ExceptionHandler]), [ExceptionHandler]),
bind(EventManager) bind(EventManager)
.toFactory( .toFactory(
(ngZone) => (ngZone) => {
{
var plugins = var plugins =
[new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()]; [new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()];
return new EventManager(plugins, ngZone); return new EventManager(plugins, ngZone);
@ -293,8 +292,7 @@ export function bootstrap(appComponentType: Type,
PromiseWrapper.then( PromiseWrapper.then(
appInjector.asyncGet(appComponentRefToken), appInjector.asyncGet(appComponentRefToken),
(componentRef) => (componentRef) => {
{
var appChangeDetector = internalView(componentRef.hostView).changeDetector; var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component // retrieve life cycle: may have already been created if injected in root component
var lc = appInjector.get(LifeCycle); var lc = appInjector.get(LifeCycle);

View File

@ -94,10 +94,8 @@ export class Compiler {
var directiveMetadata = componentBinding.metadata; var directiveMetadata = componentBinding.metadata;
return this._render.compileHost(directiveMetadata) return this._render.compileHost(directiveMetadata)
.then((hostRenderPv) => .then((hostRenderPv) => {
{ return this._compileNestedProtoViews(componentBinding, hostRenderPv, [componentBinding]);
return this._compileNestedProtoViews(componentBinding, hostRenderPv,
[componentBinding]);
}) })
.then((appProtoView) => { return new ProtoViewRef(appProtoView); }); .then((appProtoView) => { return new ProtoViewRef(appProtoView); });
} }

View File

@ -118,8 +118,8 @@ function _getAppBindings() {
TestComponentBuilder, TestComponentBuilder,
bind(NgZone).toClass(MockNgZone), bind(NgZone).toClass(MockNgZone),
bind(EventManager) bind(EventManager)
.toFactory((zone) => .toFactory(
{ (zone) => {
var plugins = [ var plugins = [
new DomEventsPlugin(), new DomEventsPlugin(),
]; ];

View File

@ -334,11 +334,10 @@ export class SpyObject {
} }
function elementText(n) { function elementText(n) {
var hasNodes = (n) => var hasNodes = (n) => {
{
var children = DOM.childNodes(n); var children = DOM.childNodes(n);
return children && children.length > 0; return children && children.length > 0;
} };
if (n instanceof Array) { if (n instanceof Array) {
return n.map((nn) => elementText(nn)).join(""); return n.map((nn) => elementText(nn)).join("");

View File

@ -240,18 +240,18 @@ export function main() {
"dynamic": (bindingRecords, variableBindings = null, directiveRecords = null, "dynamic": (bindingRecords, variableBindings = null, directiveRecords = null,
registry = null, strategy = null) => registry = null, strategy = null) =>
new DynamicProtoChangeDetector( new DynamicProtoChangeDetector(
registry, registry, new ChangeDetectorDefinition(
new ChangeDetectorDefinition( null, strategy,
null, strategy, isBlank(variableBindings) ? [] : variableBindings, isBlank(variableBindings) ? [] : variableBindings,
isBlank(bindingRecords) ? [] : bindingRecords, isBlank(bindingRecords) ? [] : bindingRecords,
isBlank(directiveRecords) ? [] : directiveRecords)), isBlank(directiveRecords) ? [] : directiveRecords)),
"JIT": "JIT": (bindingRecords, variableBindings = null, directiveRecords = null, registry = null,
(bindingRecords, variableBindings = null, directiveRecords = null, registry = null,
strategy = null) => strategy = null) =>
new JitProtoChangeDetector( new JitProtoChangeDetector(
registry, new ChangeDetectorDefinition( registry, new ChangeDetectorDefinition(
null, strategy, isBlank(variableBindings) ? [] : null,
strategy, isBlank(variableBindings) ? [] :
variableBindings, variableBindings,
isBlank(bindingRecords) ? [] : bindingRecords, isBlank(bindingRecords) ? [] : bindingRecords,
isBlank(directiveRecords) ? [] : directiveRecords)) isBlank(directiveRecords) ? [] : directiveRecords))

View File

@ -19,12 +19,8 @@ export function main() {
it("should remove non-terminal duplicate records" + it("should remove non-terminal duplicate records" +
" and update the context indices referencing them", " and update the context indices referencing them",
() => { () => {
var rs = coalesce([ var rs = coalesce(
r("user", [], 0, 1), [r("user", [], 0, 1), r("first", [], 1, 2), r("user", [], 0, 3), r("last", [], 3, 4)]);
r("first", [], 1, 2),
r("user", [], 0, 3),
r("last", [], 3, 4)
]);
expect(rs).toEqual([r("user", [], 0, 1), r("first", [], 1, 2), r("last", [], 1, 3)]); expect(rs).toEqual([r("user", [], 0, 1), r("first", [], 1, 2), r("last", [], 1, 3)]);
}); });

View File

@ -58,14 +58,12 @@ export function main() {
MapWrapper.set(m, 1, 20); MapWrapper.set(m, 1, 20);
changes.check(m); changes.check(m);
changes.forEachChangedItem((record) => changes.forEachChangedItem((record) => {
{
previous = record.previousValue; previous = record.previousValue;
current = record.currentValue; current = record.currentValue;
}) });
expect(previous) expect(previous).toEqual(10);
.toEqual(10);
expect(current).toEqual(20); expect(current).toEqual(20);
}); });
@ -97,11 +95,8 @@ export function main() {
MapWrapper.delete(m, 'b'); MapWrapper.delete(m, 'b');
changes.check(m); changes.check(m);
expect(changes.toString()) expect(changes.toString())
.toEqual(kvChangesAsString({ .toEqual(kvChangesAsString(
map: ['a', 'd'], {map: ['a', 'd'], previous: ['a', 'b[BB->null]', 'd'], removals: ['b[BB->null]']}));
previous: ['a', 'b[BB->null]', 'd'],
removals: ['b[BB->null]']
}));
MapWrapper.clear(m); MapWrapper.clear(m);
changes.check(m); changes.check(m);

View File

@ -77,8 +77,7 @@ export function main() {
} }
function captureDirective(directive): Promise<renderApi.DirectiveMetadata> { function captureDirective(directive): Promise<renderApi.DirectiveMetadata> {
return captureTemplate( return captureTemplate(new viewAnn.View({template: '<div></div>', directives: [directive]}))
new viewAnn.View({template: '<div></div>', directives: [directive]}))
.then((renderTpl) => { .then((renderTpl) => {
expect(renderTpl.directives.length).toBe(1); expect(renderTpl.directives.length).toBe(1);
return renderTpl.directives[0]; return renderTpl.directives[0];
@ -315,9 +314,11 @@ export function main() {
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]); createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
var nestedProtoView = createProtoView(); var nestedProtoView = createProtoView();
var compiler = createCompiler([ var compiler = createCompiler([
createRenderProtoView([createRenderViewportElementBinder( createRenderProtoView([
createRenderViewportElementBinder(
createRenderProtoView([createRenderComponentElementBinder(0)], createRenderProtoView([createRenderComponentElementBinder(0)],
renderApi.ProtoViewDto.EMBEDDED_VIEW_TYPE))]), renderApi.ProtoViewDto.EMBEDDED_VIEW_TYPE))
]),
createRenderProtoView() createRenderProtoView()
], ],
[[mainProtoView, viewportProtoView], [nestedProtoView]]); [[mainProtoView, viewportProtoView], [nestedProtoView]]);
@ -336,8 +337,7 @@ export function main() {
var expectedProtoView = createProtoView(); var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoView], [[expectedProtoView]]); var compiler = createCompiler([renderProtoView], [[expectedProtoView]]);
compiler.compile(MainComponent) compiler.compile(MainComponent)
.then((protoViewRef) => .then((protoViewRef) => {
{
expect(internalProtoView(protoViewRef)).toBe(expectedProtoView); expect(internalProtoView(protoViewRef)).toBe(expectedProtoView);
return compiler.compile(MainComponent); return compiler.compile(MainComponent);
}) })

View File

@ -76,27 +76,23 @@ export function main() {
view.context.ctxBoolProp = true; view.context.ctxBoolProp = true;
view.detectChanges(); view.detectChanges();
var dynamicComponent = view.rawView.viewContainers[0].views[0].locals.get("dynamic"); var dynamicComponent = view.rawView.viewContainers[0].views[0].locals.get("dynamic");
dynamicComponent.done.then((_) => var promise = dynamicComponent.done.then((_) => {
{
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('hello'); expect(view.rootNodes).toHaveText('hello');
view.context.ctxBoolProp = false; view.context.ctxBoolProp = false;
view.detectChanges(); view.detectChanges();
expect(view.rawView.viewContainers[0].views.length) expect(view.rawView.viewContainers[0].views.length).toBe(0);
.toBe(0);
expect(view.rootNodes).toHaveText(''); expect(view.rootNodes).toHaveText('');
view.context.ctxBoolProp = true; view.context.ctxBoolProp = true;
view.detectChanges(); view.detectChanges();
var dynamicComponent = var dynamicComponent = view.rawView.viewContainers[0].views[0].locals.get("dynamic");
view.rawView.viewContainers[0].views[0].locals.get(
"dynamic");
return dynamicComponent.done; return dynamicComponent.done;
}) });
.then((_) => { promise.then((_) => {
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('hello'); expect(view.rootNodes).toHaveText('hello');
async.done(); async.done();

View File

@ -112,8 +112,8 @@ export function main() {
it('should consume binding to aria-* attributes', it('should consume binding to aria-* attributes',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideView( tb.overrideView(MyComp,
MyComp, new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'})); new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
tb.createView(MyComp, {context: ctx}) tb.createView(MyComp, {context: ctx})
.then((view) => { .then((view) => {
@ -234,10 +234,12 @@ export function main() {
describe('pipes', () => { describe('pipes', () => {
beforeEachBindings(() => { beforeEachBindings(() => {
return [bind(ChangeDetection) return [
bind(ChangeDetection)
.toFactory(() => new DynamicChangeDetection( .toFactory(() => new DynamicChangeDetection(
new PipeRegistry({"double": [new DoublePipeFactory()]})), new PipeRegistry({"double": [new DoublePipeFactory()]})),
[])]; [])
];
}); });
it("should support pipes in bindings and bind config", it("should support pipes in bindings and bind config",
@ -312,8 +314,8 @@ export function main() {
it('should support directives where a selector matches property binding', it('should support directives where a selector matches property binding',
inject([TestBed, AsyncTestCompleter], (tb, async) => { inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideView(MyComp, new viewAnn.View( tb.overrideView(
{template: '<p [id]="ctxProp"></p>', directives: [IdDir]})); MyComp, new viewAnn.View({template: '<p [id]="ctxProp"></p>', directives: [IdDir]}));
tb.createView(MyComp, {context: ctx}) tb.createView(MyComp, {context: ctx})
.then((view) => { .then((view) => {
@ -1007,11 +1009,8 @@ export function main() {
</parent-providing-event-bus> </parent-providing-event-bus>
</grand-parent-providing-event-bus> </grand-parent-providing-event-bus>
`, `,
directives: [ directives:
GrandParentProvidingEventBus, [GrandParentProvidingEventBus, ParentProvidingEventBus, ChildConsumingEventBus]
ParentProvidingEventBus,
ChildConsumingEventBus
]
})); }));
tb.createView(MyComp, {context: ctx}) tb.createView(MyComp, {context: ctx})
.then((view) => { .then((view) => {
@ -1161,8 +1160,7 @@ export function main() {
tb.overrideView(MyComp, new viewAnn.View({template: inlineTpl})); tb.overrideView(MyComp, new viewAnn.View({template: inlineTpl}));
PromiseWrapper.then( PromiseWrapper.then(
tb.createView(MyComp), tb.createView(MyComp),
(value) => (value) => {
{
throw new BaseException( throw new BaseException(
"Test failure: should not have come here as an exception was expected"); "Test failure: should not have come here as an exception was expected");
}, },
@ -1638,11 +1636,15 @@ function createParentBusView(p) {
} }
@Component({ @Component({
selector: 'parent-providing-event-bus', selector: 'parent-providing-event-bus',
hostInjector: [new Binding( hostInjector: [
EventBus, {toFactory: createParentBusHost, deps: [[EventBus, new visAnn.Unbounded()]]})], new Binding(EventBus,
viewInjector: [new Binding( {toFactory: createParentBusHost, deps: [[EventBus, new visAnn.Unbounded()]]})
],
viewInjector: [
new Binding(
EventBus, EventBus,
{toFactory: createParentBusView, deps: [[FORWARD_REF(() => ParentProvidingEventBus)]]})] {toFactory: createParentBusView, deps: [[FORWARD_REF(() => ParentProvidingEventBus)]]})
]
}) })
@View({ @View({
directives: [FORWARD_REF(() => ChildConsumingEventBus)], directives: [FORWARD_REF(() => ChildConsumingEventBus)],

View File

@ -48,8 +48,7 @@ export function main() {
} }
@Directive( @Directive({selector: "[lifecycle]", properties: ['field'], lifecycle: [onChange, onCheck, onInit]})
{selector: "[lifecycle]", properties: ['field'], lifecycle: [onChange, onCheck, onInit]})
class LifecycleDir { class LifecycleDir {
field; field;
log: List<string>; log: List<string>;

View File

@ -290,8 +290,7 @@ function commonTests() {
var ran = false; var ran = false;
_zone.initCallbacks({ _zone.initCallbacks({
onTurnStart: _log.fn('onTurnStart'), onTurnStart: _log.fn('onTurnStart'),
onTurnDone: () => onTurnDone: () => {
{
_log.add('onTurnDone(begin)'); _log.add('onTurnDone(begin)');
if (!ran) { if (!ran) {
microTask(() => { microTask(() => {
@ -323,8 +322,7 @@ function commonTests() {
var ran = false; var ran = false;
_zone.initCallbacks({ _zone.initCallbacks({
onTurnStart: _log.fn('onTurnStart'), onTurnStart: _log.fn('onTurnStart'),
onTurnDone: () => onTurnDone: () => {
{
_log.add('onTurnDone(begin)'); _log.add('onTurnDone(begin)');
if (!ran) { if (!ran) {
_log.add('onTurnDone(scheduleMicrotask)'); _log.add('onTurnDone(scheduleMicrotask)');
@ -361,8 +359,7 @@ function commonTests() {
var startPromiseRan = false; var startPromiseRan = false;
_zone.initCallbacks({ _zone.initCallbacks({
onTurnStart: () => onTurnStart: () => {
{
_log.add('onTurnStart(begin)'); _log.add('onTurnStart(begin)');
if (!startPromiseRan) { if (!startPromiseRan) {
_log.add('onTurnStart(schedulePromise)'); _log.add('onTurnStart(schedulePromise)');
@ -371,8 +368,7 @@ function commonTests() {
} }
_log.add('onTurnStart(end)'); _log.add('onTurnStart(end)');
}, },
onTurnDone: () => onTurnDone: () => {
{
_log.add('onTurnDone(begin)'); _log.add('onTurnDone(begin)');
if (!donePromiseRan) { if (!donePromiseRan) {
_log.add('onTurnDone(schedulePromise)'); _log.add('onTurnDone(schedulePromise)');
@ -386,12 +382,13 @@ function commonTests() {
macroTask(() => { macroTask(() => {
_zone.run(() => { _zone.run(() => {
_log.add('run start'); _log.add('run start');
PromiseWrapper.resolve(null).then((_) => {
_log.add('promise then');
PromiseWrapper.resolve(null) PromiseWrapper.resolve(null)
.then(_log.fn('promise foo')); .then((_) => {
_log.add('promise then');
PromiseWrapper.resolve(null).then(_log.fn('promise foo'));
return PromiseWrapper.resolve(null); return PromiseWrapper.resolve(null);
}).then(_log.fn('promise bar')); })
.then(_log.fn('promise bar'));
_log.add('run end'); _log.add('run end');
}); });
}); });

View File

@ -68,9 +68,8 @@ export function main() {
it('should return a promise when instantiating a sync binding ' + it('should return a promise when instantiating a sync binding ' +
'with an async dependency', 'with an async dependency',
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
var injector = var injector = Injector.resolveAndCreate(
Injector [bind(UserList).toAsyncFactory(fetchUsers), UserController]);
.resolveAndCreate([bind(UserList).toAsyncFactory(fetchUsers), UserController]);
injector.asyncGet(UserController) injector.asyncGet(UserController)
.then(function(userController) { .then(function(userController) {
@ -145,9 +144,8 @@ export function main() {
it('should not throw when instantiating a sync binding with a resolved async dependency', it('should not throw when instantiating a sync binding with a resolved async dependency',
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
var injector = var injector = Injector.resolveAndCreate(
Injector [bind(UserList).toAsyncFactory(fetchUsers), UserController]);
.resolveAndCreate([bind(UserList).toAsyncFactory(fetchUsers), UserController]);
injector.asyncGet(UserList).then((_) => { injector.asyncGet(UserList).then((_) => {
expect(() => { injector.get(UserController); }).not.toThrow(); expect(() => { injector.get(UserController); }).not.toThrow();

View File

@ -167,9 +167,8 @@ export function main() {
}); });
it('should support overriding factory dependencies', () => { it('should support overriding factory dependencies', () => {
var injector = var injector = Injector.resolveAndCreate(
Injector [Engine, bind(Car).toFactory((e) => new SportsCar(e), [Engine])]);
.resolveAndCreate([Engine, bind(Car).toFactory((e) => new SportsCar(e), [Engine])]);
var car = injector.get(Car); var car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar); expect(car).toBeAnInstanceOf(SportsCar);
@ -191,9 +190,8 @@ export function main() {
}); });
it("should use the last binding when there are multiple bindings for same token", () => { it("should use the last binding when there are multiple bindings for same token", () => {
var injector = var injector = Injector.resolveAndCreate(
Injector [bind(Engine).toClass(Engine), bind(Engine).toClass(TurboEngine)]);
.resolveAndCreate([bind(Engine).toClass(Engine), bind(Engine).toClass(TurboEngine)]);
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine); expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
}); });
@ -278,7 +276,7 @@ export function main() {
describe("default bindings", () => { describe("default bindings", () => {
it("should be used when no matching binding found", () => { it("should be used when no matching binding found", () => {
var injector = Injector.resolveAndCreate([], { defaultBindings: true }); var injector = Injector.resolveAndCreate([], {defaultBindings: true});
var car = injector.get(Car); var car = injector.get(Car);
@ -327,7 +325,7 @@ export function main() {
}); });
it("should create child injectors without default bindings", () => { it("should create child injectors without default bindings", () => {
var parent = Injector.resolveAndCreate([], { defaultBindings: true }); var parent = Injector.resolveAndCreate([], {defaultBindings: true});
var child = parent.resolveAndCreateChild([]); var child = parent.resolveAndCreateChild([]);
// child delegates to parent the creation of Car // child delegates to parent the creation of Car
@ -393,10 +391,11 @@ export function main() {
}); });
it('should support overriding factory dependencies with dependency annotations', () => { it('should support overriding factory dependencies with dependency annotations', () => {
var bindings = Injector.resolve( var bindings = Injector.resolve([
[bind("token") bind("token")
.toFactory((e) => "result", .toFactory((e) => "result",
[[new ann.Inject("dep"), new CustomDependencyAnnotation()]])]); [[new ann.Inject("dep"), new CustomDependencyAnnotation()]])
]);
var binding = bindings[Key.get("token").id]; var binding = bindings[Key.get("token").id];
expect(binding.dependencies[0].key.token).toEqual("dep"); expect(binding.dependencies[0].key.token).toEqual("dep");

View File

@ -139,10 +139,8 @@ export function main() {
}); });
it("should support nested groups", () => { it("should support nested groups", () => {
var g = new ControlGroup({ var g = new ControlGroup(
"one": new Control("111"), {"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
"nested": new ControlGroup({"two": new Control("222")})
});
expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}}); expect(g.value).toEqual({"one": "111", "nested": {"two": "222"}});
g.controls["nested"].controls["two"].updateValue("333"); g.controls["nested"].controls["two"].updateValue("333");
@ -154,10 +152,8 @@ export function main() {
describe("find", () => { describe("find", () => {
var g; var g;
beforeEach(() => { beforeEach(() => {
g = new ControlGroup({ g = new ControlGroup(
"one": new Control("111"), {"one": new Control("111"), "nested": new ControlGroup({"two": new Control("222")})});
"nested": new ControlGroup({"two": new Control("222")})
});
}); });
it("should return a control if it is present", () => { it("should return a control if it is present", () => {

View File

@ -42,10 +42,8 @@ export function main() {
it('should not allow overriding a template after it has been resolved', () => { it('should not allow overriding a template after it has been resolved', () => {
resolver.resolve(SomeComponent); resolver.resolve(SomeComponent);
expect(() => expect(() => {
{ resolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
resolver.setView(SomeComponent,
new viewImpl.View({template: 'overridden template'}));
}) })
.toThrowError( .toThrowError(
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`); `The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
@ -101,9 +99,9 @@ export function main() {
it('should not allow overriding a directive after its template has been resolved', () => { it('should not allow overriding a directive after its template has been resolved', () => {
resolver.resolve(SomeComponent); resolver.resolve(SomeComponent);
expect( expect(() => {
() => resolver.overrideViewDirective(SomeComponent, SomeDirective, SomeOtherDirective);
{ resolver.overrideViewDirective(SomeComponent, SomeDirective, SomeOtherDirective); }) })
.toThrowError( .toThrowError(
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`); `The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
}); });

View File

@ -36,8 +36,7 @@ export function main() {
if (isBlank(directives)) directives = annotatedDirectives; if (isBlank(directives)) directives = annotatedDirectives;
return new CompilePipeline([ return new CompilePipeline([
new MockStep((parent, current, control) => new MockStep((parent, current, control) => {
{
if (isPresent(propertyBindings)) { if (isPresent(propertyBindings)) {
StringMapWrapper.forEach(propertyBindings, (ast, name) => { StringMapWrapper.forEach(propertyBindings, (ast, name) => {
current.bindElement().bindProperty(name, ast); current.bindElement().bindProperty(name, ast);

View File

@ -39,12 +39,14 @@ export function main() {
it('should inherit protoViewBuilders to children', () => { it('should inherit protoViewBuilders to children', () => {
var element = el('<div><div><span viewroot><span></span></span></div></div>'); var element = el('<div><div><span viewroot><span></span></span></div></div>');
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => { var pipeline = new CompilePipeline([
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, ProtoViewDto.EMBEDDED_VIEW_TYPE); new ProtoViewBuilder(current.element, ProtoViewDto.EMBEDDED_VIEW_TYPE);
} }
})]); })
]);
var results = pipeline.process(element); var results = pipeline.process(element);
expect(results[0].inheritedProtoView).toBe(results[1].inheritedProtoView); expect(results[0].inheritedProtoView).toBe(results[1].inheritedProtoView);
expect(results[2].inheritedProtoView).toBe(results[3].inheritedProtoView); expect(results[2].inheritedProtoView).toBe(results[3].inheritedProtoView);
@ -52,11 +54,13 @@ export function main() {
it('should inherit elementBinderBuilders to children', () => { it('should inherit elementBinderBuilders to children', () => {
var element = el('<div bind><div><span bind><span></span></span></div></div>'); var element = el('<div bind><div><span bind><span></span></span></div></div>');
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => { var pipeline = new CompilePipeline([
new MockStep((parent, current, control) => {
if (isPresent(DOM.getAttribute(current.element, 'bind'))) { if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
current.bindElement(); current.bindElement();
} }
})]); })
]);
var results = pipeline.process(element); var results = pipeline.process(element);
expect(results[0].inheritedElementBinder).toBe(results[1].inheritedElementBinder); expect(results[0].inheritedElementBinder).toBe(results[1].inheritedElementBinder);
expect(results[2].inheritedElementBinder).toBe(results[3].inheritedElementBinder); expect(results[2].inheritedElementBinder).toBe(results[3].inheritedElementBinder);
@ -70,11 +74,13 @@ export function main() {
it('should calculate distanceToParent / parent correctly', () => { it('should calculate distanceToParent / parent correctly', () => {
var element = el('<div bind><div bind></div><div><div bind></div></div></div>'); var element = el('<div bind><div bind></div><div><div bind></div></div></div>');
var pipeline = new CompilePipeline([new MockStep((parent, current, control) => { var pipeline = new CompilePipeline([
new MockStep((parent, current, control) => {
if (isPresent(DOM.getAttribute(current.element, 'bind'))) { if (isPresent(DOM.getAttribute(current.element, 'bind'))) {
current.bindElement(); current.bindElement();
} }
})]); })
]);
var results = pipeline.process(element); var results = pipeline.process(element);
expect(results[0].inheritedElementBinder.distanceToParent).toBe(0); expect(results[0].inheritedElementBinder.distanceToParent).toBe(0);
expect(results[1].inheritedElementBinder.distanceToParent).toBe(1); expect(results[1].inheritedElementBinder.distanceToParent).toBe(1);
@ -101,8 +107,8 @@ export function main() {
var element = el('<div id="1"><span wrap0="1" id="2"><b id="3"></b></span></div>'); var element = el('<div id="1"><span wrap0="1" id="2"><b id="3"></b></span></div>');
var step0Log = []; var step0Log = [];
var step1Log = []; var step1Log = [];
var pipeline = new CompilePipeline( var pipeline =
[createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]); new CompilePipeline([createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
var result = pipeline.process(element); var result = pipeline.process(element);
expect(step0Log).toEqual(['1', '1<2', '2<3']); expect(step0Log).toEqual(['1', '1<2', '2<3']);
expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<2', '2<3']); expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<2', '2<3']);
@ -149,8 +155,8 @@ export function main() {
var element = el('<div id="1"><span wrap0="2" id="2"><b id="3"></b></span></div>'); var element = el('<div id="1"><span wrap0="2" id="2"><b id="3"></b></span></div>');
var step0Log = []; var step0Log = [];
var step1Log = []; var step1Log = [];
var pipeline = new CompilePipeline( var pipeline =
[createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]); new CompilePipeline([createWrapperStep('wrap0', step0Log), createLoggerStep(step1Log)]);
var result = pipeline.process(element); var result = pipeline.process(element);
expect(step0Log).toEqual(['1', '1<2', '2<3']); expect(step0Log).toEqual(['1', '1<2', '2<3']);
expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<wrap0#1', 'wrap0#1<2', '2<3']); expect(step1Log).toEqual(['1', '1<wrap0#0', 'wrap0#0<wrap0#1', 'wrap0#1<2', '2<3']);
@ -165,8 +171,7 @@ export function main() {
var resultLog = []; var resultLog = [];
var newChild = new CompileElement(el('<div id="3"></div>')); var newChild = new CompileElement(el('<div id="3"></div>'));
var pipeline = new CompilePipeline([ var pipeline = new CompilePipeline([
new MockStep((parent, current, control) => new MockStep((parent, current, control) => {
{
if (StringWrapper.equals(DOM.getAttribute(current.element, 'id'), '1')) { if (StringWrapper.equals(DOM.getAttribute(current.element, 'id'), '1')) {
control.addChild(newChild); control.addChild(newChild);
} }

View File

@ -15,8 +15,7 @@ export function main() {
describe('PropertyBindingParser', () => { describe('PropertyBindingParser', () => {
function createPipeline(hasNestedProtoView = false) { function createPipeline(hasNestedProtoView = false) {
return new CompilePipeline([ return new CompilePipeline([
new MockStep((parent, current, control) => new MockStep((parent, current, control) => {
{
if (hasNestedProtoView) { if (hasNestedProtoView) {
current.bindElement().bindNestedProtoView(el('<template></template>')); current.bindElement().bindNestedProtoView(el('<template></template>'));
} }

View File

@ -52,8 +52,7 @@ export function main() {
xhr.expect('base/foo', 'xhr template'); xhr.expect('base/foo', 'xhr template');
var template = new ViewDefinition({absUrl: 'base/foo'}); var template = new ViewDefinition({absUrl: 'base/foo'});
loader.load(template) loader.load(template)
.then((el) => .then((el) => {
{
expect(DOM.content(el)).toHaveText('xhr template'); expect(DOM.content(el)).toHaveText('xhr template');
firstEl = el; firstEl = el;
return loader.load(template); return loader.load(template);

View File

@ -58,8 +58,7 @@ export function main() {
inject([AsyncTestCompleter, DomTestbed], (async, tb) => { inject([AsyncTestCompleter, DomTestbed], (async, tb) => {
tb.compileAll([ tb.compileAll([
someComponent, someComponent,
new ViewDefinition( new ViewDefinition({componentId: 'someComponent', template: 'hello', directives: []})
{componentId: 'someComponent', template: 'hello', directives: []})
]) ])
.then((protoViewDtos) => { .then((protoViewDtos) => {
var rootView = tb.createRootView(protoViewDtos[0]); var rootView = tb.createRootView(protoViewDtos[0]);
@ -74,8 +73,7 @@ export function main() {
it('should update text nodes', inject([AsyncTestCompleter, DomTestbed], (async, tb) => { it('should update text nodes', inject([AsyncTestCompleter, DomTestbed], (async, tb) => {
tb.compileAll([ tb.compileAll([
someComponent, someComponent,
new ViewDefinition( new ViewDefinition({componentId: 'someComponent', template: '{{a}}', directives: []})
{componentId: 'someComponent', template: '{{a}}', directives: []})
]) ])
.then((protoViewDtos) => { .then((protoViewDtos) => {
var rootView = tb.createRootView(protoViewDtos[0]); var rootView = tb.createRootView(protoViewDtos[0]);

View File

@ -158,10 +158,11 @@ export function main() {
it("should include view container nodes", () => { it("should include view container nodes", () => {
var lightDomEl = el("<div><template></template></div>"); var lightDomEl = el("<div><template></template></div>");
var lightDom = createLightDom( var lightDom = createLightDom(
new FakeView( new FakeView([
[new FakeViewContainer(DOM.firstChild(lightDomEl), // template element new FakeViewContainer(DOM.firstChild(lightDomEl), // template element
[el('<a></a>')] // light DOM nodes of view container [el('<a></a>')] // light DOM nodes of view container
)]), )
]),
null, lightDomEl); null, lightDomEl);
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]); expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);
@ -169,11 +170,13 @@ export function main() {
it("should include content nodes", () => { it("should include content nodes", () => {
var lightDomEl = el("<div><content></content></div>"); var lightDomEl = el("<div><content></content></div>");
var lightDom = createLightDom( var lightDom =
new FakeView([new FakeContentTag(DOM.firstChild(lightDomEl), // content element createLightDom(new FakeView([
new FakeContentTag(DOM.firstChild(lightDomEl), // content element
'', // selector '', // selector
[el('<a></a>')] // light DOM nodes of content tag [el('<a></a>')] // light DOM nodes of content tag
)]), )
]),
null, lightDomEl); null, lightDomEl);
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]); expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);

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) => .toFactory((styleUrlResolver) => new EmulatedUnscopedShadowDomStrategy(
new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, null), styleUrlResolver, null),
[StyleUrlResolver]) [StyleUrlResolver])
}; };
if (DOM.supportsNativeShadowDOM()) { if (DOM.supportsNativeShadowDOM()) {
@ -404,8 +404,8 @@ var mainDir =
var simple = new DirectiveMetadata( var simple = new DirectiveMetadata(
{selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'simple', id: 'simple', type: DirectiveMetadata.COMPONENT_TYPE});
var empty = new DirectiveMetadata( var empty =
{selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE}); new DirectiveMetadata({selector: 'empty', id: 'empty', type: DirectiveMetadata.COMPONENT_TYPE});
var dynamicComponent = new DirectiveMetadata( var dynamicComponent = new DirectiveMetadata(
{selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'dynamic', id: 'dynamic', type: DirectiveMetadata.COMPONENT_TYPE});
@ -425,11 +425,11 @@ var outerWithIndirectNestedComponent = new DirectiveMetadata({
type: DirectiveMetadata.COMPONENT_TYPE type: DirectiveMetadata.COMPONENT_TYPE
}); });
var outerComponent = new DirectiveMetadata( var outerComponent =
{selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE}); new DirectiveMetadata({selector: 'outer', id: 'outer', type: DirectiveMetadata.COMPONENT_TYPE});
var innerComponent = new DirectiveMetadata( var innerComponent =
{selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE}); new DirectiveMetadata({selector: 'inner', id: 'inner', type: DirectiveMetadata.COMPONENT_TYPE});
var innerInnerComponent = new DirectiveMetadata( var innerInnerComponent = new DirectiveMetadata(
{selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE}); {selector: 'innerinner', id: 'innerinner', type: DirectiveMetadata.COMPONENT_TYPE});

View File

@ -46,8 +46,9 @@ export function main() {
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
bind(Location).toClass(SpyLocation), bind(Location).toClass(SpyLocation),
bind(Router).toFactory((registry, pipeline, location) => bind(Router)
{ return new RootRouter(registry, pipeline, location, MyComp); }, .toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
[RouteRegistry, Pipeline, Location]) [RouteRegistry, Pipeline, Location])
]); ]);
@ -60,10 +61,10 @@ export function main() {
})); }));
function compile(template: string = "<router-outlet></router-outlet>") { function compile(template: string = "<router-outlet></router-outlet>") {
tb.overrideView(MyComp, new annotations.View({ tb.overrideView(
template: ('<div>' + template + '</div>'), MyComp,
directives: [RouterOutlet, RouterLink] new annotations.View(
})); {template: ('<div>' + template + '</div>'), directives: [RouterOutlet, RouterLink]}));
return tb.createView(MyComp, {context: ctx}).then((v) => { view = v; }); return tb.createView(MyComp, {context: ctx}).then((v) => { view = v; });
} }
@ -84,8 +85,7 @@ export function main() {
compile() compile()
.then((_) => rtr.config({'path': '/user/:name', 'component': UserCmp})) .then((_) => rtr.config({'path': '/user/:name', 'component': UserCmp}))
.then((_) => rtr.navigate('/user/brian')) .then((_) => rtr.navigate('/user/brian'))
.then((_) => .then((_) => {
{
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('hello brian'); expect(view.rootNodes).toHaveText('hello brian');
}) })
@ -116,8 +116,7 @@ export function main() {
.then((_) => rtr.config({'path': '/ab', 'components': {'left': A, 'right': B}})) .then((_) => rtr.config({'path': '/ab', 'components': {'left': A, 'right': B}}))
.then((_) => rtr.config({'path': '/ba', 'components': {'left': B, 'right': A}})) .then((_) => rtr.config({'path': '/ba', 'components': {'left': B, 'right': A}}))
.then((_) => rtr.navigate('/ab')) .then((_) => rtr.navigate('/ab'))
.then((_) => .then((_) => {
{
view.detectChanges(); view.detectChanges();
expect(view.rootNodes).toHaveText('left { A } | right { B }'); expect(view.rootNodes).toHaveText('left { A } | right { B }');
}) })
@ -175,8 +174,7 @@ export function main() {
compile() compile()
.then((_) => rtr.config({'path': '/team/:id', 'component': TeamCmp})) .then((_) => rtr.config({'path': '/team/:id', 'component': TeamCmp}))
.then((_) => rtr.navigate('/team/angular/user/rado')) .then((_) => rtr.navigate('/team/angular/user/rado'))
.then((_) => .then((_) => {
{
view.detectChanges(); view.detectChanges();
expect(teamCmpCount).toBe(1); expect(teamCmpCount).toBe(1);
expect(view.rootNodes).toHaveText('team angular { hello rado }'); expect(view.rootNodes).toHaveText('team angular { hello rado }');

View File

@ -34,8 +34,9 @@ export function main() {
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
bind(Location).toClass(SpyLocation), bind(Location).toClass(SpyLocation),
bind(Router).toFactory((registry, pipeline, location) => bind(Router)
{ return new RootRouter(registry, pipeline, location, AppCmp); }, .toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, AppCmp); },
[RouteRegistry, Pipeline, Location]) [RouteRegistry, Pipeline, Location])
]); ]);
@ -78,8 +79,7 @@ export function main() {
router.registerOutlet(outlet) router.registerOutlet(outlet)
.then((_) => router.navigate('/a')) .then((_) => router.navigate('/a'))
.then((_) => .then((_) => {
{
expect(outlet.spy('activate')).not.toHaveBeenCalled(); expect(outlet.spy('activate')).not.toHaveBeenCalled();
return router.config({'path': '/a', 'component': 'A'}); return router.config({'path': '/a', 'component': 'A'});
}) })

View File

@ -36,8 +36,7 @@ export function main() {
}); });
it('should ignore the base path when the url has a scheme', it('should ignore the base path when the url has a scheme',
() => () => {
{
expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com')) expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com'))
.toEqual('http://www.bar.com'); .toEqual('http://www.bar.com');
}) })

View File

@ -58,11 +58,8 @@ export class MdInputContainer {
selector: 'md-input-container input', selector: 'md-input-container input',
events: ['mdChange', 'mdFocusChange'], events: ['mdChange', 'mdFocusChange'],
hostProperties: {'yes': 'class.md-input'}, hostProperties: {'yes': 'class.md-input'},
hostListeners: { hostListeners:
'input': 'updateValue($event)', {'input': 'updateValue($event)', 'focus': 'setHasFocus(true)', 'blur': 'setHasFocus(false)'}
'focus': 'setHasFocus(true)',
'blur': 'setHasFocus(false)'
}
}) })
export class MdInput { export class MdInput {
value: string; value: string;

View File

@ -23,16 +23,14 @@ export function setupReflector() {
// TODO(kegluneq): Generate this. // TODO(kegluneq): Generate this.
reflector.registerSetters({ reflector.registerSetters({
'style': (o, m) => 'style': (o, m) => {
{
// HACK // HACK
MapWrapper.forEach(m, function(v, k) { o.style.setProperty(k, v); }); MapWrapper.forEach(m, function(v, k) { o.style.setProperty(k, v); });
} }
}); });
reflector.registerMethods({ reflector.registerMethods({
'onScroll': (o, args) => 'onScroll': (o, args) => {
{
// HACK // HACK
o.onScroll(args[0]); o.onScroll(args[0]);
}, },

View File

@ -44,8 +44,7 @@ var data = require("sdk/self").data;
mod.PageMod({ mod.PageMod({
include: ['*'], include: ['*'],
contentScriptFile: data.url("installed_script.js"), contentScriptFile: data.url("installed_script.js"),
onAttach: worker => onAttach: worker => {
{
worker.port.on('startProfiler', () => startProfiler()); worker.port.on('startProfiler', () => startProfiler());
worker.port.on('stopAndRecord', filePath => stopAndRecord(filePath)); worker.port.on('stopAndRecord', filePath => stopAndRecord(filePath));
worker.port.on('forceGC', () => forceGC()); worker.port.on('forceGC', () => forceGC());

View File

@ -23,8 +23,8 @@ export class SampleDescription {
toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; } toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
} }
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},
@ -41,4 +41,5 @@ var _BINDINGS =
Validator, Validator,
Options.DEFAULT_DESCRIPTION, Options.DEFAULT_DESCRIPTION,
Options.SAMPLE_DESCRIPTION Options.SAMPLE_DESCRIPTION
])]; ])
];

View File

@ -95,8 +95,8 @@ export class SampleState {
constructor(public completeSample: List<any>, public validSample: List<any>) {} constructor(public completeSample: List<any>, public validSample: List<any>) {}
} }
var _BINDINGS = var _BINDINGS = [
[bind(Sampler) bind(Sampler)
.toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({ .toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
driver: driver, driver: driver,
reporter: reporter, reporter: reporter,
@ -117,4 +117,5 @@ var _BINDINGS =
Options.PREPARE, Options.PREPARE,
Options.EXECUTE, Options.EXECUTE,
Options.NOW Options.NOW
])]; ])
];

View File

@ -20,8 +20,8 @@ export class WebDriverExtension {
ListWrapper.map(childTokens, (token) => injector.asyncGet(token))), ListWrapper.map(childTokens, (token) => injector.asyncGet(token))),
[Injector]), [Injector]),
bind(WebDriverExtension) bind(WebDriverExtension)
.toFactory((children, capabilities) => .toFactory(
{ (children, capabilities) => {
var delegate; var delegate;
ListWrapper.forEach(children, (extension) => { ListWrapper.forEach(children, (extension) => {
if (extension.supports(capabilities)) { if (extension.supports(capabilities)) {
@ -29,8 +29,7 @@ export class WebDriverExtension {
} }
}); });
if (isBlank(delegate)) { if (isBlank(delegate)) {
throw new BaseException( throw new BaseException('Could not find a delegate for given capabilities!');
'Could not find a delegate for given capabilities!');
} }
return delegate; return delegate;
}, },

View File

@ -132,5 +132,7 @@ function normalizeEvent(chromeEvent: StringMap<string, any>,
return result; return result;
} }
var _BINDINGS = [bind(ChromeDriverExtension) var _BINDINGS = [
.toFactory((driver) => new ChromeDriverExtension(driver), [WebDriverAdapter])]; bind(ChromeDriverExtension)
.toFactory((driver) => new ChromeDriverExtension(driver), [WebDriverAdapter])
];

View File

@ -128,5 +128,7 @@ function createMarkEndEvent(name, time) {
return createEvent('e', name, time); return createEvent('e', name, time);
} }
var _BINDINGS = [bind(IOsDriverExtension) var _BINDINGS = [
.toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])]; bind(IOsDriverExtension)
.toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])
];

View File

@ -44,8 +44,7 @@ export function main() {
PerflogMetric.BINDINGS, PerflogMetric.BINDINGS,
bind(Options.MICRO_METRICS).toValue(microMetrics), bind(Options.MICRO_METRICS).toValue(microMetrics),
bind(PerflogMetric.SET_TIMEOUT) bind(PerflogMetric.SET_TIMEOUT)
.toValue((fn, millis) => .toValue((fn, millis) => {
{
ListWrapper.push(commandLog, ['setTimeout', millis]); ListWrapper.push(commandLog, ['setTimeout', millis]);
fn(); fn();
}), }),
@ -125,12 +124,14 @@ export function main() {
it('should mark and aggregate events in between the marks', it('should mark and aggregate events in between the marks',
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
var events = [[ var events = [
[
eventFactory.markStart('benchpress0', 0), eventFactory.markStart('benchpress0', 0),
eventFactory.start('script', 4), eventFactory.start('script', 4),
eventFactory.end('script', 6), eventFactory.end('script', 6),
eventFactory.markEnd('benchpress0', 10) eventFactory.markEnd('benchpress0', 10)
]]; ]
];
var metric = createMetric(events); var metric = createMetric(events);
metric.beginMeasure() metric.beginMeasure()
.then((_) => metric.endMeasure(false)) .then((_) => metric.endMeasure(false))
@ -224,8 +225,7 @@ export function main() {
var metric = createMetric(events); var metric = createMetric(events);
metric.beginMeasure() metric.beginMeasure()
.then((_) => metric.endMeasure(true)) .then((_) => metric.endMeasure(true))
.then((data) => .then((data) => {
{
expect(data['scriptTime']).toBe(0); expect(data['scriptTime']).toBe(0);
return metric.endMeasure(true) return metric.endMeasure(true)
}) })
@ -247,7 +247,8 @@ export function main() {
describe('with forced gc', () => { describe('with forced gc', () => {
var events; var events;
beforeEach(() => { beforeEach(() => {
events = [[ events = [
[
eventFactory.markStart('benchpress0', 0), eventFactory.markStart('benchpress0', 0),
eventFactory.start('script', 4), eventFactory.start('script', 4),
eventFactory.end('script', 6), eventFactory.end('script', 6),
@ -256,7 +257,8 @@ export function main() {
eventFactory.start('gc', 12, {'usedHeapSize': 2500}), eventFactory.start('gc', 12, {'usedHeapSize': 2500}),
eventFactory.end('gc', 15, {'usedHeapSize': 1000}), eventFactory.end('gc', 15, {'usedHeapSize': 1000}),
eventFactory.markEnd('benchpress1', 20) eventFactory.markEnd('benchpress1', 20)
]]; ]
];
}); });
it('should measure forced gc', inject([AsyncTestCompleter], (async) => { it('should measure forced gc', inject([AsyncTestCompleter], (async) => {
@ -359,14 +361,16 @@ export function main() {
it('should ignore events from different processed as the start mark', it('should ignore events from different processed as the start mark',
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
var otherProcessEventFactory = new TraceEventFactory('timeline', 'pid1'); var otherProcessEventFactory = new TraceEventFactory('timeline', 'pid1');
var metric = createMetric([[ var metric = createMetric([
[
eventFactory.markStart('benchpress0', 0), eventFactory.markStart('benchpress0', 0),
eventFactory.start('script', 0, null), eventFactory.start('script', 0, null),
eventFactory.end('script', 5, null), eventFactory.end('script', 5, null),
otherProcessEventFactory.start('script', 10, null), otherProcessEventFactory.start('script', 10, null),
otherProcessEventFactory.end('script', 17, null), otherProcessEventFactory.end('script', 17, null),
eventFactory.markEnd('benchpress0', 20) eventFactory.markEnd('benchpress0', 20)
]]); ]
]);
metric.beginMeasure() metric.beginMeasure()
.then((_) => metric.endMeasure(false)) .then((_) => metric.endMeasure(false))
.then((data) => { .then((data) => {

View File

@ -30,8 +30,7 @@ export function main() {
bind(JsonFileReporter.PATH).toValue(path), bind(JsonFileReporter.PATH).toValue(path),
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, 'filename': filename,
'content': content 'content': content
@ -58,11 +57,13 @@ export function main() {
.toEqual({ .toEqual({
"description": "description":
{"id": "someId", "description": {"a": 2}, "metrics": {"script": "script time"}}, {"id": "someId", "description": {"a": 2}, "metrics": {"script": "script time"}},
"completeSample": [{ "completeSample": [
{
"timeStamp": "1970-01-01T00:00:00.000Z", "timeStamp": "1970-01-01T00:00:00.000Z",
"runIndex": 0, "runIndex": 0,
"values": {"a": 3, "b": 6} "values": {"a": 3, "b": 6}
}], }
],
"validSample": [ "validSample": [
{ {
"timeStamp": "1970-01-01T00:00:00.000Z", "timeStamp": "1970-01-01T00:00:00.000Z",

View File

@ -36,8 +36,8 @@ export function main() {
} }
runner = new Runner([ runner = new Runner([
defaultBindings, defaultBindings,
bind(Sampler).toFactory((_injector) => bind(Sampler).toFactory(
{ (_injector) => {
injector = _injector; injector = _injector;
return new MockSampler(); return new MockSampler();
}, },
@ -61,8 +61,7 @@ export function main() {
it('should merge SampleDescription.description', inject([AsyncTestCompleter], (async) => { it('should merge SampleDescription.description', inject([AsyncTestCompleter], (async) => {
createRunner([bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 1})]) createRunner([bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 1})])
.sample( .sample({id: 'someId', bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue({'b': 2})]})
{id: 'someId', bindings: [bind(Options.SAMPLE_DESCRIPTION).toValue({'b': 2})]})
.then((_) => injector.asyncGet(SampleDescription)) .then((_) => injector.asyncGet(SampleDescription))
.then((desc) => { .then((desc) => {

View File

@ -151,15 +151,14 @@ export function main() {
var iterationCount = 1; var iterationCount = 1;
createSampler({ createSampler({
validator: createCountingValidator(2), validator: createCountingValidator(2),
metric: new MockMetric([], () => metric: new MockMetric([],
{ () => {
var result = PromiseWrapper.resolve({'script': scriptTime}); var result = PromiseWrapper.resolve({'script': scriptTime});
scriptTime = 0; scriptTime = 0;
return result; return result;
}), }),
prepare: () => { scriptTime = 1 * iterationCount; }, prepare: () => { scriptTime = 1 * iterationCount; },
execute: () => execute: () => {
{
scriptTime = 10 * iterationCount; scriptTime = 10 * iterationCount;
iterationCount++; iterationCount++;
} }
@ -192,11 +191,8 @@ export function main() {
expect(log.length).toBe(2); expect(log.length).toBe(2);
expect(log[0]).toEqual(['validate', [mv(0, 1000, {'script': 0})], null]); expect(log[0]).toEqual(['validate', [mv(0, 1000, {'script': 0})], null]);
expect(log[1]).toEqual([ expect(log[1]).toEqual(
'validate', ['validate', [mv(0, 1000, {'script': 0}), mv(1, 1001, {'script': 1})], validSample]);
[mv(0, 1000, {'script': 0}), mv(1, 1001, {'script': 1})],
validSample
]);
async.done(); async.done();
}); });

View File

@ -135,8 +135,10 @@ export function main() {
})); }));
it('should ignore FunctionCalls from webdriver', inject([AsyncTestCompleter], (async) => { it('should ignore FunctionCalls from webdriver', inject([AsyncTestCompleter], (async) => {
createExtension([chromeTimelineEvents.start( createExtension([
'FunctionCall', 0, {'data': {'scriptName': 'InjectedScript'}})]) chromeTimelineEvents.start('FunctionCall', 0,
{'data': {'scriptName': 'InjectedScript'}})
])
.readPerfLog() .readPerfLog()
.then((events) => { .then((events) => {
expect(events).toEqual([]); expect(events).toEqual([]);
@ -270,8 +272,7 @@ class MockDriverAdapter extends WebDriverAdapter {
if (type === 'performance') { if (type === 'performance') {
return PromiseWrapper.resolve(this._events.map((event) => { return PromiseWrapper.resolve(this._events.map((event) => {
return { return {
'message': 'message': Json.stringify({'message': {'method': this._messageMethod, 'params': event}})
Json.stringify({'message': {'method': this._messageMethod, 'params': event}})
}; };
})); }));
} else { } else {

View File

@ -181,8 +181,7 @@ class SurveyBuilder {
// We are disabling the responseLength control when the question type is checkbox. // We are disabling the responseLength control when the question type is checkbox.
var typeCtrl: Control = newQuestion.controls['type']; var typeCtrl: Control = newQuestion.controls['type'];
ObservableWrapper.subscribe(typeCtrl.valueChanges, ObservableWrapper.subscribe(typeCtrl.valueChanges, (v) => v == 'text' || v == 'textarea' ?
(v) => v == 'text' || v == 'textarea' ?
newQuestion.include('responseLength') : newQuestion.include('responseLength') :
newQuestion.exclude('responseLength')); newQuestion.exclude('responseLength'));

View File

@ -4199,7 +4199,7 @@
} }
}, },
"clang-format": { "clang-format": {
"version": "1.0.15" "version": "1.0.17"
} }
} }
}, },

6
npm-shrinkwrap.json generated
View File

@ -6488,9 +6488,9 @@
} }
}, },
"clang-format": { "clang-format": {
"version": "1.0.15", "version": "1.0.17",
"from": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.15.tgz", "from": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.17.tgz",
"resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.15.tgz" "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.17.tgz"
} }
} }
}, },

View File

@ -50,8 +50,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
let pathsToEmit = []; let pathsToEmit = [];
let pathsWithErrors = []; let pathsWithErrors = [];
treeDiff.changedPaths treeDiff.changedPaths.forEach((tsFilePath) => {
.forEach((tsFilePath) => {
if (!this.fileRegistry[tsFilePath]) { if (!this.fileRegistry[tsFilePath]) {
this.fileRegistry[tsFilePath] = {version: 0}; this.fileRegistry[tsFilePath] = {version: 0};
this.rootFilePaths.push(tsFilePath); this.rootFilePaths.push(tsFilePath);
@ -62,8 +61,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
pathsToEmit.push(tsFilePath); pathsToEmit.push(tsFilePath);
}); });
treeDiff.removedPaths treeDiff.removedPaths.forEach((tsFilePath) => {
.forEach((tsFilePath) => {
console.log('removing outputs for', tsFilePath); console.log('removing outputs for', tsFilePath);
this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1); this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1);
@ -136,9 +134,10 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
let errorMessages = []; let errorMessages = [];
allDiagnostics.forEach(diagnostic => { allDiagnostics.forEach(diagnostic => {
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
errorMessages.push(` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); errorMessages.push(
` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
}); });
if (errorMessages.length) { if (errorMessages.length) {

View File

@ -110,8 +110,7 @@ describe('TreeDiffer', () => {
'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)}),
'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}), 'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
'subdir-1': { 'subdir-1': {
'file-1.1.txt': 'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
} }
}, },
'symlinks': { 'symlinks': {

View File

@ -129,7 +129,7 @@ class DirtyCheckingDiffResult {
public startTime: number = Date.now(); public startTime: number = Date.now();
public endTime: number = null; public endTime: number = null;
constructor(public label:string, public directoryName: string) {} constructor(public label: string, public directoryName: string) {}
toString() { toString() {
return `${pad(this.label, 30)}, ${pad(this.endTime - this.startTime, 5)}ms, ` + return `${pad(this.label, 30)}, ${pad(this.endTime - this.startTime, 5)}ms, ` +

View File

@ -84,11 +84,13 @@ module.exports = function makeNodeTree(destinationPath) {
// TODO: remove this when we no longer use traceur // TODO: remove this when we no longer use traceur
var traceurCompatibleTsModulesTree = replace(modulesTree, { var traceurCompatibleTsModulesTree = replace(modulesTree, {
files: ['**/*.ts'], files: ['**/*.ts'],
patterns: [{ patterns: [
{
// Empty replacement needed so that replaceWithPath gets triggered... // Empty replacement needed so that replaceWithPath gets triggered...
match: /$/g, match: /$/g,
replacement: "" replacement: ""
}], }
],
replaceWithPath: function(path, content) { replaceWithPath: function(path, content) {
if (!path.endsWith('.d.ts')) { if (!path.endsWith('.d.ts')) {
content += '\r\nexport var __esModule = true;\n'; content += '\r\nexport var __esModule = true;\n';
@ -120,11 +122,13 @@ module.exports = function makeNodeTree(destinationPath) {
return "var parse5Adapter = require('angular2/src/dom/parse5_adapter'); " + return "var parse5Adapter = require('angular2/src/dom/parse5_adapter'); " +
"parse5Adapter.Parse5DomAdapter.makeCurrent();" + content; "parse5Adapter.Parse5DomAdapter.makeCurrent();" + content;
}, },
patterns: [{ patterns: [
{
// Append main() to all tests since all of our tests are wrapped in exported main fn // Append main() to all tests since all of our tests are wrapped in exported main fn
match: /$/g, match: /$/g,
replacement: "\r\n main();" replacement: "\r\n main();"
}] }
]
}); });
return destCopy(nodeTree, destinationPath); return destCopy(nodeTree, destinationPath);