style(dart): Run dartfmt v0.1.8+2 on all pure Dart code

Update formatting for all pure Dart code in the repo.
This commit is contained in:
Tim Blasi 2015-07-27 17:26:28 -07:00
parent 6fac901151
commit 2c9951273a
63 changed files with 406 additions and 273 deletions

View File

@ -15,8 +15,7 @@ export 'package:angular2/src/change_detection/directive_record.dart'
show DirectiveIndex, DirectiveRecord;
export 'package:angular2/src/change_detection/interfaces.dart'
show ChangeDetector, ChangeDetectorDefinition, ProtoChangeDetector;
export 'package:angular2/src/change_detection/pipes/pipes.dart'
show Pipes;
export 'package:angular2/src/change_detection/pipes/pipes.dart' show Pipes;
export 'package:angular2/src/change_detection/proto_record.dart'
show ProtoRecord;
export 'package:angular2/src/change_detection/change_detection_util.dart'
@ -27,8 +26,7 @@ typedef ProtoChangeDetector PregenProtoChangeDetectorFactory(
ChangeDetectorDefinition definition);
typedef ChangeDetector InstantiateMethod(dynamic dispatcher,
List<ProtoRecord> protoRecords,
List<DirectiveRecord> directiveRecords);
List<ProtoRecord> protoRecords, List<DirectiveRecord> directiveRecords);
/// Implementation of [ProtoChangeDetector] for use by pre-generated change
/// detectors in Angular 2 Dart.
@ -52,19 +50,19 @@ class PregenProtoChangeDetector extends ProtoChangeDetector {
static bool isSupported() => true;
factory PregenProtoChangeDetector(InstantiateMethod instantiateMethod,
ChangeDetectorDefinition def) {
factory PregenProtoChangeDetector(
InstantiateMethod instantiateMethod, ChangeDetectorDefinition def) {
// TODO(kegluneq): Pre-generate these (#2067).
var recordBuilder = new ProtoRecordBuilder();
def.bindingRecords.forEach((b) {
recordBuilder.add(b, def.variableNames);
});
var protoRecords = coalesce(recordBuilder.records);
return new PregenProtoChangeDetector._(def.id, instantiateMethod,
protoRecords, def.directiveRecords);
return new PregenProtoChangeDetector._(
def.id, instantiateMethod, protoRecords, def.directiveRecords);
}
@override
instantiate(dynamic dispatcher) => _instantiateMethod(
dispatcher, _protoRecords, _directiveRecords);
instantiate(dynamic dispatcher) =>
_instantiateMethod(dispatcher, _protoRecords, _directiveRecords);
}

View File

@ -3,7 +3,8 @@ library angular2.application;
import 'dart:async';
import 'package:angular2/src/reflection/reflection.dart' show reflector;
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
import 'package:angular2/src/reflection/reflection_capabilities.dart'
show ReflectionCapabilities;
import 'application_common.dart';
export 'application_common.dart' show ApplicationRef;

View File

@ -6,8 +6,7 @@ import 'application_common.dart';
/// Starts an application from a root component.
///
/// See [commonBootstrap] for detailed documentation.
Future<ApplicationRef> bootstrapStatic(
Type appComponentType,
Future<ApplicationRef> bootstrapStatic(Type appComponentType,
[List componentInjectableBindings]) {
return commonBootstrap(appComponentType, componentInjectableBindings);
}

View File

@ -10,7 +10,8 @@ import './interface_query.dart';
* In the future this class will implement an Observable interface.
* For now it uses a plain list of observable callbacks.
*/
class QueryList<T> extends Object with IterableMixin<T> implements IQueryList<T> {
class QueryList<T> extends Object with IterableMixin<T>
implements IQueryList<T> {
List<T> _results = [];
List _callbacks = [];
bool _dirty = false;

View File

@ -11,7 +11,6 @@ typedef void ErrorHandlingFn(error, stackTrace);
* is cancelled.
*/
class WrappedTimer implements Timer {
Timer _timer;
ZeroArgFunction _onCancelCb;
@ -124,7 +123,8 @@ class NgZone {
*
* This hook is useful for validating application state (e.g. in a test).
*/
void overrideOnEventDone(ZeroArgFunction onEventDoneFn, [bool waitForAsync = false]) {
void overrideOnEventDone(ZeroArgFunction onEventDoneFn,
[bool waitForAsync = false]) {
_onEventDone = onEventDoneFn;
if (waitForAsync) {
@ -264,7 +264,8 @@ class NgZone {
}
}
Timer _createTimer(Zone self, ZoneDelegate parent, Zone zone, Duration duration, fn()) {
Timer _createTimer(
Zone self, ZoneDelegate parent, Zone zone, Duration duration, fn()) {
WrappedTimer wrappedTimer;
var cb = () {
fn();

View File

@ -7,40 +7,40 @@ export 'metadata.dart';
* {@link InjectMetadata}.
*/
class Inject extends InjectMetadata {
const Inject(dynamic token): super(token);
const Inject(dynamic token) : super(token);
}
/**
* {@link OptionalMetadata}.
*/
class Optional extends OptionalMetadata {
const Optional(): super();
const Optional() : super();
}
/**
* {@link InjectableMetadata}.
*/
class Injectable extends InjectableMetadata {
const Injectable(): super();
const Injectable() : super();
}
/**
* {@link SelfMetadata}.
*/
class Self extends SelfMetadata {
const Self(): super();
const Self() : super();
}
/**
* {@link AncestorMetadata}.
*/
class Ancestor extends AncestorMetadata {
const Ancestor({bool self}): super(self:self);
const Ancestor({bool self}) : super(self: self);
}
/**
* {@link UnboundedMetadata}.
*/
class Unbounded extends UnboundedMetadata {
const Unbounded({bool self}): super(self:self);
}
const Unbounded({bool self}) : super(self: self);
}

View File

@ -41,16 +41,16 @@ class ObservableListDiff extends IterableChanges {
_updated = false;
return super.transform(collection, args);
// An update has been registered since the last change detection check.
// - We reset the flag.
// - We diff the collection.
} else if (_updated){
// An update has been registered since the last change detection check.
// - We reset the flag.
// - We diff the collection.
} else if (_updated) {
_updated = false;
return super.transform(collection, args);
return super.transform(collection, args);
// No updates has been registered.
// Returning this tells change detection that object has not change,
// so it should NOT update the binding.
// No updates has been registered.
// Returning this tells change detection that object has not change,
// so it should NOT update the binding.
} else {
return this;
}

View File

@ -392,7 +392,6 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
}
var baseElement = null;
String getBaseElementHref() {
if (baseElement == null) {

View File

@ -17,20 +17,25 @@ class Html5LibDomAdapter implements DomAdapter {
return true;
}
void setProperty(Element element, String name, Object value) => throw 'not implemented';
void setProperty(Element element, String name, Object value) =>
throw 'not implemented';
getProperty(Element element, String name) => throw 'not implemented';
invoke(Element element, String methodName, List args) => throw 'not implemented';
invoke(Element element, String methodName, List args) =>
throw 'not implemented';
logError(error) {
stderr.writeln('${error}');
}
log(error) { stdout.writeln('${error}'); }
logGroup(error) { stdout.writeln('${error}'); }
logGroupEnd() { }
log(error) {
stdout.writeln('${error}');
}
logGroup(error) {
stdout.writeln('${error}');
}
logGroupEnd() {}
@override
final attrToPropMap = const {
@ -245,8 +250,8 @@ class Html5LibDomAdapter implements DomAdapter {
}
getAttribute(element, String attribute) {
// `attributes` keys can be {@link AttributeName}s.
var key = element.attributes.keys.firstWhere(
(key) => '$key' == attribute, orElse: () {});
var key = element.attributes.keys.firstWhere((key) => '$key' == attribute,
orElse: () {});
return element.attributes[key];
}
setAttribute(element, String name, String value) {

View File

@ -29,7 +29,8 @@ class PromiseWrapper {
return promise.catchError(onError);
}
static PromiseCompleter<dynamic> completer() => new PromiseCompleter(new Completer());
static PromiseCompleter<dynamic> completer() =>
new PromiseCompleter(new Completer());
}
class TimerWrapper {

View File

@ -4,18 +4,12 @@ import 'package:intl/intl.dart';
String _normalizeLocale(String locale) => locale.replaceAll('-', '_');
enum NumberFormatStyle {
DECIMAL,
PERCENT,
CURRENCY
}
enum NumberFormatStyle { DECIMAL, PERCENT, CURRENCY }
class NumberFormatter {
static String format(num number, String locale, NumberFormatStyle style,
{int minimumIntegerDigits: 1,
int minimumFractionDigits: 0,
int maximumFractionDigits: 3,
String currency,
{int minimumIntegerDigits: 1, int minimumFractionDigits: 0,
int maximumFractionDigits: 3, String currency,
bool currencyAsSymbol: false}) {
locale = _normalizeLocale(locale);
NumberFormat formatter;
@ -29,7 +23,8 @@ class NumberFormatter {
case NumberFormatStyle.CURRENCY:
if (currencyAsSymbol) {
// See https://github.com/dart-lang/intl/issues/59.
throw new Exception('Displaying currency as symbol is not supported.');
throw new Exception(
'Displaying currency as symbol is not supported.');
}
formatter = new NumberFormat.currencyPattern(locale, currency);
break;

View File

@ -201,7 +201,8 @@ class BaseException extends Error {
final originalException;
final originalStack;
BaseException([this.message, this.originalException, this.originalStack, this.context]);
BaseException(
[this.message, this.originalException, this.originalStack, this.context]);
String toString() {
return this.message;

View File

@ -1,4 +1,5 @@
library angular2.src.http.backends.browser_jsonp;
import 'package:angular2/di.dart';
import 'dart:html' show document;
import 'dart:js' show context, JsObject, JsArray;
@ -50,7 +51,9 @@ class BrowserJsonp {
}
// Attach the <script> element to the DOM
send(dynamic node) { document.body.append(node); }
send(dynamic node) {
document.body.append(node);
}
// Remove <script> element from the DOM
cleanup(dynamic node) {

View File

@ -5,7 +5,7 @@ import 'package:angular2/di.dart';
@Injectable()
class BrowserXhr {
HttpRequest build() {
return new HttpRequest();
}
HttpRequest build() {
return new HttpRequest();
}
}

View File

@ -1,4 +1,5 @@
library angular2.src.http.http_utils;
import 'dart:js' show JsObject;
import 'dart:collection' show LinkedHashMap, LinkedHashSet;

View File

@ -49,37 +49,188 @@ class ReflectionCapabilities implements PlatformReflectionCapabilities {
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]).reflectee;
case 11:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) => create(
name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11]).reflectee;
case 12:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => create(
name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12
]).reflectee;
case 13:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13]).reflectee;
create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13
]).reflectee;
case 14:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14]).reflectee;
create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14
]).reflectee;
case 15:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15
]).reflectee;
case 16:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16
]).reflectee;
case 17:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17
]).reflectee;
case 18:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18]).reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18
]).reflectee;
case 19:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19]).
reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18, a19) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19
]).reflectee;
case 20:
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) =>
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20]).
reflectee;
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
a15, a16, a17, a18, a19, a20) => create(name, [
a1,
a2,
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10,
a11,
a12,
a13,
a14,
a15,
a16,
a17,
a18,
a19,
a20
]).reflectee;
}
throw "Cannot create a factory for '${stringify(type)}' because its constructor has more than 20 arguments";

View File

@ -101,7 +101,8 @@ class Expect extends gns.Expect {
void toThrowErrorWith(message) => expectException(this.actual, message);
void toBePromise() => gns.guinness.matchers.toBeTrue(actual is Future);
void toImplement(expected) => toBeA(expected);
void toBeNaN() => gns.guinness.matchers.toBeTrue(double.NAN.compareTo(actual) == 0);
void toBeNaN() =>
gns.guinness.matchers.toBeTrue(double.NAN.compareTo(actual) == 0);
void toHaveText(expected) => _expect(elementText(actual), expected);
void toHaveBeenCalledWith([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) =>
_expect(_argsMatch(actual, a, b, c, d, e, f), true,

View File

@ -78,7 +78,8 @@ class _CodegenState {
_CodegenState._(this._changeDetectorDefId, this._contextTypeName,
this._changeDetectorTypeName, String changeDetectionStrategy,
List<ProtoRecord> records, List<DirectiveRecord> directiveRecords, this._generateCheckNoChanges)
List<ProtoRecord> records, List<DirectiveRecord> directiveRecords,
this._generateCheckNoChanges)
: _records = records,
_directiveRecords = directiveRecords,
_names = new CodegenNameUtil(records, directiveRecords, '_', _UTIL),
@ -92,7 +93,8 @@ class _CodegenState {
.forEach((rec) => protoRecords.add(rec, def.variableNames));
var records = coalesce(protoRecords.records);
return new _CodegenState._(def.id, typeName, changeDetectorTypeName,
def.strategy, records, def.directiveRecords, def.generateCheckNoChanges);
def.strategy, records, def.directiveRecords,
def.generateCheckNoChanges);
}
void _writeToBuf(StringBuffer buf) {

View File

@ -5,8 +5,7 @@ import 'dart:async';
import 'dart:core';
import 'package:angular2/src/web-workers/shared/message_bus.dart'
show MessageBus, MessageBusSink, MessageBusSource;
import 'package:angular2/src/web-workers/ui/impl.dart'
show bootstrapUICommon;
import 'package:angular2/src/web-workers/ui/impl.dart' show bootstrapUICommon;
/**
* Bootstrapping a WebWorker
@ -23,7 +22,7 @@ void bootstrap(String uri) {
/**
* To be called from the main thread to spawn and communicate with the worker thread
*/
Future<UIMessageBus> spawnWorker(Uri uri){
Future<UIMessageBus> spawnWorker(Uri uri) {
var receivePort = new ReceivePort();
var isolateEndSendPort = receivePort.sendPort;
return Isolate.spawnUri(uri, const [], isolateEndSendPort).then((_) {
@ -57,7 +56,8 @@ class UIMessageBusSink extends MessageBusSink {
class UIMessageBusSource extends MessageBusSource {
final ReceivePort _port;
final Stream rawDataStream;
Map<int, StreamSubscription> _listenerStore = new Map<int, StreamSubscription>();
Map<int, StreamSubscription> _listenerStore =
new Map<int, StreamSubscription>();
int _numListeners = 0;
UIMessageBusSource(ReceivePort port)
@ -68,8 +68,8 @@ class UIMessageBusSource extends MessageBusSource {
return message is SendPort;
});
int addListener(Function fn){
var subscription = rawDataStream.listen((message){
int addListener(Function fn) {
var subscription = rawDataStream.listen((message) {
fn({"data": message});
});
@ -77,7 +77,7 @@ class UIMessageBusSource extends MessageBusSource {
return _numListeners;
}
void removeListener(int index){
void removeListener(int index) {
_listenerStore[index].cancel();
_listenerStore.remove(index);
}

View File

@ -3,7 +3,7 @@ library angular2.src.web_workers.worker;
import "package:angular2/src/web-workers/shared/message_bus.dart"
show MessageBus, MessageBusSource, MessageBusSink;
import "package:angular2/src/web-workers/worker/application_common.dart"
show bootstrapWebworkerCommon;
show bootstrapWebworkerCommon;
import "package:angular2/src/facade/async.dart" show Future;
import "package:angular2/src/core/application.dart" show ApplicationRef;
import "package:angular2/src/facade/lang.dart" show Type, BaseException;
@ -27,8 +27,8 @@ Future<ApplicationRef> bootstrapWebworker(
[List<dynamic> componentInjectableBindings = null]) {
ReceivePort rPort = new ReceivePort();
WorkerMessageBus bus = new WorkerMessageBus.fromPorts(replyTo, rPort);
return bootstrapWebworkerCommon(appComponentType, bus,
componentInjectableBindings);
return bootstrapWebworkerCommon(
appComponentType, bus, componentInjectableBindings);
}
class WorkerMessageBus extends MessageBus {
@ -57,15 +57,16 @@ class WorkerMessageBusSink extends MessageBusSink {
class WorkerMessageBusSource extends MessageBusSource {
final ReceivePort _port;
final Stream rawDataStream;
Map<int, StreamSubscription> _listenerStore = new Map<int, StreamSubscription>();
Map<int, StreamSubscription> _listenerStore =
new Map<int, StreamSubscription>();
int _numListeners = 0;
WorkerMessageBusSource(ReceivePort rPort)
: _port = rPort,
rawDataStream = rPort.asBroadcastStream();
int addListener(Function fn){
var subscription = rawDataStream.listen((message){
int addListener(Function fn) {
var subscription = rawDataStream.listen((message) {
fn({"data": message});
});
@ -73,7 +74,7 @@ class WorkerMessageBusSource extends MessageBusSource {
return _numListeners;
}
void removeListener(int index){
void removeListener(int index) {
_listenerStore[index].cancel();
_listenerStore.remove(index);
}

View File

@ -18,8 +18,8 @@ main() {
});
it("should be true when the lifecycle includes onChange", () {
expect(metadata(DirectiveNoHooks,
new Directive(lifecycle: [LifecycleEvent.onChange])).callOnChange).toBe(true);
expect(metadata(DirectiveNoHooks, new Directive(
lifecycle: [LifecycleEvent.onChange])).callOnChange).toBe(true);
});
it("should be false otherwise", () {
@ -40,8 +40,8 @@ main() {
});
it("should be true when the lifecycle includes onDestroy", () {
expect(metadata(DirectiveNoHooks,
new Directive(lifecycle: [LifecycleEvent.onDestroy])).callOnDestroy).toBe(true);
expect(metadata(DirectiveNoHooks, new Directive(
lifecycle: [LifecycleEvent.onDestroy])).callOnDestroy).toBe(true);
});
it("should be false otherwise", () {
@ -58,8 +58,8 @@ main() {
});
it("should be true when the lifecycle includes onCheck", () {
expect(metadata(DirectiveNoHooks,
new Directive(lifecycle: [LifecycleEvent.onCheck])).callOnCheck).toBe(true);
expect(metadata(DirectiveNoHooks, new Directive(
lifecycle: [LifecycleEvent.onCheck])).callOnCheck).toBe(true);
});
it("should be false otherwise", () {
@ -77,7 +77,8 @@ main() {
it("should be true when the lifecycle includes onInit", () {
expect(metadata(DirectiveNoHooks,
new Directive(lifecycle: [LifecycleEvent.onInit])).callOnInit).toBe(true);
new Directive(lifecycle: [LifecycleEvent.onInit])).callOnInit)
.toBe(true);
});
it("should be false otherwise", () {
@ -94,7 +95,9 @@ main() {
it("should be true when the lifecycle includes onAllChangesDone", () {
expect(metadata(DirectiveNoHooks, new Directive(
lifecycle: [LifecycleEvent.onAllChangesDone])).callOnAllChangesDone).toBe(true);
lifecycle: [
LifecycleEvent.onAllChangesDone
])).callOnAllChangesDone).toBe(true);
});
it("should be false otherwise", () {

View File

@ -45,13 +45,15 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '<type-literal-component></type-literal-component>',
directives: [TypeLiteralComponent]))
.createAsync(Dummy).then((tc) {
tb
.overrideView(Dummy, new View(
template: '<type-literal-component></type-literal-component>',
directives: [TypeLiteralComponent]))
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
expect(asNativeElements(tc.componentViewChildren)).toHaveText('[Hello, World]');
expect(asNativeElements(tc.componentViewChildren))
.toHaveText('[Hello, World]');
async.done();
});
}));
@ -62,11 +64,12 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '<throwing-component></throwing-component>',
directives: [ThrowingComponent]))
.createAsync(Dummy).catchError((e, stack) {
tb
.overrideView(Dummy, new View(
template: '<throwing-component></throwing-component>',
directives: [ThrowingComponent]))
.createAsync(Dummy)
.catchError((e, stack) {
expect(e).toContainError("MockException");
expect(e).toContainError("functionThatThrows");
async.done();
@ -77,11 +80,12 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '<throwing-component2></throwing-component2>',
directives: [ThrowingComponent2]))
.createAsync(Dummy).catchError((e, stack) {
tb
.overrideView(Dummy, new View(
template: '<throwing-component2></throwing-component2>',
directives: [ThrowingComponent2]))
.createAsync(Dummy)
.catchError((e, stack) {
expect(e).toContainError("NonError");
expect(e).toContainError("functionThatThrows");
async.done();
@ -94,13 +98,15 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '<property-access></property-access>',
directives: [PropertyAccess]))
.createAsync(Dummy).then((tc) {
tb
.overrideView(Dummy, new View(
template: '<property-access></property-access>',
directives: [PropertyAccess]))
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
expect(asNativeElements(tc.componentViewChildren)).toHaveText('prop:foo-prop;map:foo-map');
expect(asNativeElements(tc.componentViewChildren))
.toHaveText('prop:foo-prop;map:foo-map');
async.done();
});
}));
@ -109,11 +115,12 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '<no-property-access></no-property-access>',
directives: [NoPropertyAccess]))
.createAsync(Dummy).then((tc) {
tb
.overrideView(Dummy, new View(
template: '<no-property-access></no-property-access>',
directives: [NoPropertyAccess]))
.createAsync(Dummy)
.then((tc) {
expect(() => tc.detectChanges())
.toThrowError(new RegExp('property not found'));
async.done();
@ -126,11 +133,12 @@ main() {
TestComponentBuilder,
AsyncTestCompleter
], (tb, async) {
tb.overrideView(Dummy, new View(
template: '''<on-change [prop]="'hello'"></on-change>''',
directives: [OnChangeComponent]))
.createAsync(Dummy).then((tc) {
tb
.overrideView(Dummy, new View(
template: '''<on-change [prop]="'hello'"></on-change>''',
directives: [OnChangeComponent]))
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
var cmp = tc.componentViewChildren[0].inject(OnChangeComponent);
expect(cmp.prop).toEqual('hello');
@ -141,13 +149,17 @@ main() {
});
describe("ObservableListDiff", () {
it('should be notified of changes', inject([TestComponentBuilder, Log], fakeAsync((TestComponentBuilder tcb, Log log) {
tcb.overrideView(Dummy, new View(
template: '''<component-with-observable-list [list]="value"></component-with-observable-list>''',
directives: [ComponentWithObservableList]))
.createAsync(Dummy).then((tc) {
tc.componentInstance.value = new ObservableList.from([1,2]);
it('should be notified of changes', inject([
TestComponentBuilder,
Log
], fakeAsync((TestComponentBuilder tcb, Log log) {
tcb
.overrideView(Dummy, new View(
template: '''<component-with-observable-list [list]="value"></component-with-observable-list>''',
directives: [ComponentWithObservableList]))
.createAsync(Dummy)
.then((tc) {
tc.componentInstance.value = new ObservableList.from([1, 2]);
tc.detectChanges();
@ -170,7 +182,7 @@ main() {
expect(asNativeElements(tc.componentViewChildren)).toHaveText('123');
// we replaced the list => a check
tc.componentInstance.value = new ObservableList.from([5,6,7]);
tc.componentInstance.value = new ObservableList.from([5, 6, 7]);
tc.detectChanges();
@ -257,22 +269,29 @@ class OnChangeComponent implements OnChange {
changeDetection: ON_PUSH,
properties: const ['list'],
hostInjector: const [
const Binding(Pipes, toValue: const Pipes (const {"iterableDiff": const [const ObservableListDiffFactory(), const IterableChangesFactory(), const NullPipeFactory()]}))
const Binding(Pipes,
toValue: const Pipes(const {
"iterableDiff": const [
const ObservableListDiffFactory(),
const IterableChangesFactory(),
const NullPipeFactory()
]
)
@View(template: '<span *ng-for="#item of list">{{item}}</span><directive-logging-checks></directive-logging-checks>', directives: const [NgFor, DirectiveLoggingChecks])
class ComponentWithObservableList {
}))
])
@View(
template: '<span *ng-for="#item of list">{{item}}</span><directive-logging-checks></directive-logging-checks>',
directives: const [NgFor, DirectiveLoggingChecks])
class ComponentWithObservableList {
Iterable list;
}
@Directive(
selector: 'directive-logging-checks',
lifecycle: const [LifecycleEvent.onCheck]
)
selector: 'directive-logging-checks',
lifecycle: const [LifecycleEvent.onCheck])
class DirectiveLoggingChecks implements OnCheck {
Log log;
DirectiveLoggingChecks(this.log);
onCheck() => log.add("check");
}
}

View File

@ -19,30 +19,32 @@ main() {
});
it("should be false otherwise", () {
expect(pipeFactory.supports([1,2,3])).toBe(false);
expect(pipeFactory.supports([1, 2, 3])).toBe(false);
});
});
it("should return the wrapped value to trigger change detection on first invocation of transform", () {
it("should return the wrapped value to trigger change detection on first invocation of transform",
() {
final pipe = pipeFactory.create(changeDetectorRef);
final c = new ObservableList.from([1,2]);
final c = new ObservableList.from([1, 2]);
expect(pipe.transform(c, []).wrapped).toBe(pipe);
});
it("should return itself when no changes between the calls", () {
final pipe = pipeFactory.create(changeDetectorRef);
final c = new ObservableList.from([1,2]);
final c = new ObservableList.from([1, 2]);
pipe.transform(c, []);
expect(pipe.transform(c, [])).toBe(pipe);
});
it("should return the wrapped value once a change has been trigger", fakeAsync(() {
it("should return the wrapped value once a change has been trigger",
fakeAsync(() {
final pipe = pipeFactory.create(changeDetectorRef);
final c = new ObservableList.from([1,2]);
final c = new ObservableList.from([1, 2]);
pipe.transform(c, []);
@ -56,10 +58,11 @@ main() {
expect(pipe.transform(c, []).wrapped).toBe(pipe);
}));
it("should request a change detection check upon receiving a change", fakeAsync(() {
it("should request a change detection check upon receiving a change",
fakeAsync(() {
final pipe = pipeFactory.create(changeDetectorRef);
final c = new ObservableList.from([1,2]);
final c = new ObservableList.from([1, 2]);
pipe.transform(c, []);
c.add(3);
@ -71,20 +74,21 @@ main() {
it("should return the wrapped value after changing a collection", () {
final pipe = pipeFactory.create(changeDetectorRef);
final c1 = new ObservableList.from([1,2]);
final c2 = new ObservableList.from([3,4]);
final c1 = new ObservableList.from([1, 2]);
final c2 = new ObservableList.from([3, 4]);
expect(pipe.transform(c1, []).wrapped).toBe(pipe);
expect(pipe.transform(c2, []).wrapped).toBe(pipe);
});
it("should not unbsubscribe from the stream of chagnes after changing a collection", () {
it("should not unbsubscribe from the stream of chagnes after changing a collection",
() {
final pipe = pipeFactory.create(changeDetectorRef);
final c1 = new ObservableList.from([1,2]);
final c1 = new ObservableList.from([1, 2]);
expect(pipe.transform(c1, []).wrapped).toBe(pipe);
final c2 = new ObservableList.from([3,4]);
final c2 = new ObservableList.from([3, 4]);
expect(pipe.transform(c2, []).wrapped).toBe(pipe);
// pushing into the first collection has no effect, and we do not see the change
@ -92,4 +96,4 @@ main() {
expect(pipe.transform(c2, [])).toBe(pipe);
});
});
}
}

View File

@ -6,4 +6,4 @@ library angular2.test.router.route_config_spec;
* The rest of the router tests have typed annotations, so there's no need to add
* additional tests here for Dart.
*/
main () {}
main() {}

View File

@ -30,7 +30,6 @@ void initReflector() {
], const [], () => new MixedSoupComponent(), const [OnChange]))
..registerType(MatchedSoupComponent, new _ngRef.ReflectionInfo(const [
const Component(
selector: '[soup]',
lifecycle: const [LifecycleEvent.onChange])
selector: '[soup]', lifecycle: const [LifecycleEvent.onChange])
], const [], () => new MatchedSoupComponent(), const [OnChange]));
}

View File

@ -91,7 +91,9 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
_alreadyChecked = true;
}
void checkNoChanges() {this.runDetectChanges(true);}
void checkNoChanges() {
this.runDetectChanges(true);
}
void callOnAllChangesDone() {
dispatcher.notifyOnAllChangesDone();

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.change_detection_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.compiler_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.costs_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.di_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.element_injector_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.largetable_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.naive_infinite_scroll_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.naive_infinite_scroll_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.selector_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.static_tree_perf;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchmarks.e2e_test.tree_perf;
main() {
}
main() {}

View File

@ -38,8 +38,8 @@ main() {
TreeNode createData() {
var values = count++ % 2 == 0
? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*']
: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*']
: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
return buildTree(MAX_DEPTH, values, 0);
}
@ -62,8 +62,7 @@ main() {
@Component(
selector: 'tree0',
map: const {'data': '=>data'},
template: '<span> {{data.value}} '
)
template: '<span> {{data.value}} ')
class TreeComponent0 {
var data;
}
@ -71,8 +70,7 @@ class TreeComponent0 {
@Component(
selector: 'tree1',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree0 data=data.right></tree0><tree0 data=data.left></tree0>'
)
template: '<span> {{data.value}} <tree0 data=data.right></tree0><tree0 data=data.left></tree0>')
class TreeComponent1 {
var data;
}
@ -80,8 +78,7 @@ class TreeComponent1 {
@Component(
selector: 'tree2',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree1 data=data.right></tree1><tree1 data=data.left></tree1>'
)
template: '<span> {{data.value}} <tree1 data=data.right></tree1><tree1 data=data.left></tree1>')
class TreeComponent2 {
var data;
}
@ -89,8 +86,7 @@ class TreeComponent2 {
@Component(
selector: 'tree3',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree2 data=data.right></tree2><tree2 data=data.left></tree2>'
)
template: '<span> {{data.value}} <tree2 data=data.right></tree2><tree2 data=data.left></tree2>')
class TreeComponent3 {
var data;
}
@ -98,8 +94,7 @@ class TreeComponent3 {
@Component(
selector: 'tree4',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree3 data=data.right></tree3><tree3 data=data.left></tree3>'
)
template: '<span> {{data.value}} <tree3 data=data.right></tree3><tree3 data=data.left></tree3>')
class TreeComponent4 {
var data;
}
@ -107,8 +102,7 @@ class TreeComponent4 {
@Component(
selector: 'tree5',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree4 data=data.right></tree4><tree4 data=data.left></tree4>'
)
template: '<span> {{data.value}} <tree4 data=data.right></tree4><tree4 data=data.left></tree4>')
class TreeComponent5 {
var data;
}
@ -116,8 +110,7 @@ class TreeComponent5 {
@Component(
selector: 'tree6',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree5 data=data.right></tree5><tree5 data=data.left></tree5>'
)
template: '<span> {{data.value}} <tree5 data=data.right></tree5><tree5 data=data.left></tree5>')
class TreeComponent6 {
var data;
}
@ -125,8 +118,7 @@ class TreeComponent6 {
@Component(
selector: 'tree7',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree6 data=data.right></tree6><tree6 data=data.left></tree6>'
)
template: '<span> {{data.value}} <tree6 data=data.right></tree6><tree6 data=data.left></tree6>')
class TreeComponent7 {
var data;
}
@ -134,8 +126,7 @@ class TreeComponent7 {
@Component(
selector: 'tree8',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree7 data=data.right></tree7><tree7 data=data.left></tree7>'
)
template: '<span> {{data.value}} <tree7 data=data.right></tree7><tree7 data=data.left></tree7>')
class TreeComponent8 {
var data;
}
@ -143,8 +134,7 @@ class TreeComponent8 {
@Component(
selector: 'tree9',
map: const {'data': '=>data'},
template: '<span> {{data.value}} <tree8 data=data.right></tree8><tree8 data=data.left></tree8>'
)
template: '<span> {{data.value}} <tree8 data=data.right></tree8><tree8 data=data.left></tree8>')
class TreeComponent9 {
var data;
}

View File

@ -1,2 +1,3 @@
library benchpress.index;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.src.firefox_extension.data.installed_script;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.src.firefox_extension.lib.main;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.src.firefox_extension.lib.parser_util;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.src.firefox_extension.lib.test_helper;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.src.webdriver.selenium_webdriver_adapter;
//no dart implementation

View File

@ -1,2 +1,3 @@
library benchpress.test.firefox_extension.conf;
//empty as we don't have a version for dart

View File

@ -1,5 +1,3 @@
library benchpress.test.firefox_extension.parser_util_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchpress.test.firefox_extension.sample_benchmark;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library benchpress.test.firefox_extension.spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.async_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.hello_world.hello_world_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.http.http_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.jsonp.jsonp_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.key_events.key_events_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.message_bus;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.hello_world.model_driven_forms_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.order_management_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.person_management_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.sourcemap.sourcemap_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.hello_world.template_driven_forms_spec;
main() {
}
main() {}

View File

@ -1,5 +1,3 @@
library examples.e2e_test.zippy_component.zippy_spec;
main() {
}
main() {}

View File

@ -8,7 +8,6 @@ void commonDemoSetup() {
}
class DemoUrlResolver extends UrlResolver {
@override
String resolve(String baseUrl, String url) {
const MATERIAL_PKG = 'package:angular2_material/';
@ -16,7 +15,8 @@ class DemoUrlResolver extends UrlResolver {
// We run a proxy server in front of pub serve that prepends "example" to
// paths
if (url.startsWith(MATERIAL_PKG)) {
return '/examples/packages/angular2_material/' + url.substring(MATERIAL_PKG.length);
return '/examples/packages/angular2_material/' +
url.substring(MATERIAL_PKG.length);
}
return super.resolve(baseUrl, url);
}

View File

@ -2,11 +2,12 @@ library examples.src.web_workers.index;
import "index_common.dart" show HelloCmp;
import "dart:isolate";
import "package:angular2/src/web-workers/worker/application.dart" show bootstrapWebworker;
import "package:angular2/src/web-workers/worker/application.dart"
show bootstrapWebworker;
import "package:angular2/src/reflection/reflection_capabilities.dart";
import "package:angular2/src/reflection/reflection.dart";
main(List<String> args, SendPort replyTo){
main(List<String> args, SendPort replyTo) {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrapWebworker(replyTo, HelloCmp);
}

View File

@ -4,7 +4,7 @@ import "package:angular2/src/web-workers/ui/application.dart" show bootstrap;
import "package:angular2/src/reflection/reflection_capabilities.dart";
import "package:angular2/src/reflection/reflection.dart";
main(){
main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap("background_index.dart");
}