style(dart): Format Dart source with dart_style 0.1.8
This commit is contained in:
parent
eb2784eb81
commit
ffb219fb91
@ -1,2 +1,3 @@
|
|||||||
library angular2.sfx;
|
library angular2.sfx;
|
||||||
// empty as we don't have a version for Dart
|
|
||||||
|
// empty as we don't have a version for Dart
|
||||||
|
@ -13,20 +13,16 @@ bool hasLifecycleHook(LifecycleEvent e, type, Directive annotation) {
|
|||||||
|
|
||||||
if (e == onChange) {
|
if (e == onChange) {
|
||||||
interface = OnChange;
|
interface = OnChange;
|
||||||
|
|
||||||
} else if (e == onDestroy) {
|
} else if (e == onDestroy) {
|
||||||
interface = OnDestroy;
|
interface = OnDestroy;
|
||||||
|
|
||||||
} else if (e == onAllChangesDone) {
|
} else if (e == onAllChangesDone) {
|
||||||
interface = OnAllChangesDone;
|
interface = OnAllChangesDone;
|
||||||
|
|
||||||
} else if (e == onCheck) {
|
} else if (e == onCheck) {
|
||||||
interface = OnCheck;
|
interface = OnCheck;
|
||||||
|
|
||||||
} else if (e == onInit) {
|
} else if (e == onInit) {
|
||||||
interface = OnInit;
|
interface = OnInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return interfaces.contains(interface);
|
return interfaces.contains(interface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,15 +52,13 @@ class NgZone {
|
|||||||
_mountZone = Zone.current;
|
_mountZone = Zone.current;
|
||||||
|
|
||||||
if (enableLongStackTrace) {
|
if (enableLongStackTrace) {
|
||||||
_innerZone = Chain.capture(
|
_innerZone = Chain.capture(() => _createInnerZone(Zone.current),
|
||||||
() => _createInnerZone(Zone.current),
|
|
||||||
onError: _onErrorWithLongStackTrace);
|
onError: _onErrorWithLongStackTrace);
|
||||||
} else {
|
} else {
|
||||||
_innerZone = _createInnerZone(
|
_innerZone = _createInnerZone(Zone.current,
|
||||||
Zone.current,
|
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
|
||||||
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, error, StackTrace trace) =>
|
error,
|
||||||
_onErrorWithoutLongStackTrace(error, trace)
|
StackTrace trace) => _onErrorWithoutLongStackTrace(error, trace));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +73,8 @@ class NgZone {
|
|||||||
* @param {Function} onTurnDone called at the end of a VM turn if code has executed in the inner zone
|
* @param {Function} onTurnDone called at the end of a VM turn if code has executed in the inner zone
|
||||||
* @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task
|
* @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task
|
||||||
*/
|
*/
|
||||||
void initCallbacks({Function onTurnStart, Function onTurnDone, Function onErrorHandler}) {
|
void initCallbacks(
|
||||||
|
{Function onTurnStart, Function onTurnDone, Function onErrorHandler}) {
|
||||||
_onTurnStart = onTurnStart;
|
_onTurnStart = onTurnStart;
|
||||||
_onTurnDone = onTurnDone;
|
_onTurnDone = onTurnDone;
|
||||||
_onErrorHandler = onErrorHandler;
|
_onErrorHandler = onErrorHandler;
|
||||||
@ -158,10 +157,10 @@ class NgZone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dynamic _runUnary(Zone self, ZoneDelegate parent, Zone zone, fn(arg), arg) =>
|
dynamic _runUnary(Zone self, ZoneDelegate parent, Zone zone, fn(arg), arg) =>
|
||||||
_run(self, parent, zone, () => fn(arg));
|
_run(self, parent, zone, () => fn(arg));
|
||||||
|
|
||||||
dynamic _runBinary(Zone self, ZoneDelegate parent, Zone zone, fn(arg1, arg2), arg1, arg2) =>
|
dynamic _runBinary(Zone self, ZoneDelegate parent, Zone zone, fn(arg1, arg2),
|
||||||
_run(self, parent, zone, () => fn(arg1, arg2));
|
arg1, arg2) => _run(self, parent, zone, () => fn(arg1, arg2));
|
||||||
|
|
||||||
void _scheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, fn) {
|
void _scheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, fn) {
|
||||||
_pendingMicrotasks++;
|
_pendingMicrotasks++;
|
||||||
@ -196,14 +195,12 @@ class NgZone {
|
|||||||
|
|
||||||
Zone _createInnerZone(Zone zone, {handleUncaughtError}) {
|
Zone _createInnerZone(Zone zone, {handleUncaughtError}) {
|
||||||
return zone.fork(
|
return zone.fork(
|
||||||
specification: new ZoneSpecification(
|
specification: new ZoneSpecification(
|
||||||
scheduleMicrotask: _scheduleMicrotask,
|
scheduleMicrotask: _scheduleMicrotask,
|
||||||
run: _run,
|
run: _run,
|
||||||
runUnary: _runUnary,
|
runUnary: _runUnary,
|
||||||
runBinary: _runBinary,
|
runBinary: _runBinary,
|
||||||
handleUncaughtError: handleUncaughtError
|
handleUncaughtError: handleUncaughtError),
|
||||||
),
|
zoneValues: {'_innerZone': true});
|
||||||
zoneValues: {'_innerZone': true}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||||||
MouseEvent createMouseEvent(String eventType) =>
|
MouseEvent createMouseEvent(String eventType) =>
|
||||||
new MouseEvent(eventType, canBubble: true);
|
new MouseEvent(eventType, canBubble: true);
|
||||||
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
|
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
|
||||||
void preventDefault(Event evt) {
|
void preventDefault(Event evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
}
|
}
|
||||||
String getInnerHTML(Element el) => el.innerHtml;
|
String getInnerHTML(Element el) => el.innerHtml;
|
||||||
|
@ -76,7 +76,7 @@ class Html5LibDomAdapter implements DomAdapter {
|
|||||||
createEvent(eventType) {
|
createEvent(eventType) {
|
||||||
throw 'not implemented';
|
throw 'not implemented';
|
||||||
}
|
}
|
||||||
preventDefault(evt) {
|
preventDefault(evt) {
|
||||||
throw 'not implemented';
|
throw 'not implemented';
|
||||||
}
|
}
|
||||||
getInnerHTML(el) {
|
getInnerHTML(el) {
|
||||||
|
@ -6,13 +6,8 @@ export 'dart:async' show Future, Stream, StreamController, StreamSubscription;
|
|||||||
class PromiseWrapper {
|
class PromiseWrapper {
|
||||||
static Future resolve(obj) => new Future.value(obj);
|
static Future resolve(obj) => new Future.value(obj);
|
||||||
|
|
||||||
static Future reject(obj, stackTrace) => new Future.error(
|
static Future reject(obj, stackTrace) => new Future.error(obj,
|
||||||
obj,
|
stackTrace != null ? stackTrace : obj is Error ? obj.stackTrace : null);
|
||||||
stackTrace != null
|
|
||||||
? stackTrace
|
|
||||||
: obj is Error
|
|
||||||
? obj.stackTrace
|
|
||||||
: null);
|
|
||||||
|
|
||||||
static Future<List> all(List<Future> promises) => Future.wait(promises);
|
static Future<List> all(List<Future> promises) => Future.wait(promises);
|
||||||
|
|
||||||
@ -35,15 +30,17 @@ class PromiseWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TimerWrapper {
|
class TimerWrapper {
|
||||||
static Timer setTimeout(fn(), int millis)
|
static Timer setTimeout(fn(), int millis) =>
|
||||||
=> new Timer(new Duration(milliseconds: millis), fn);
|
new Timer(new Duration(milliseconds: millis), fn);
|
||||||
static void clearTimeout(Timer timer) {
|
static void clearTimeout(Timer timer) {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Timer setInterval(fn(), int millis) {
|
static Timer setInterval(fn(), int millis) {
|
||||||
var interval = new Duration(milliseconds: millis);
|
var interval = new Duration(milliseconds: millis);
|
||||||
return new Timer.periodic(interval, (Timer timer) { fn(); });
|
return new Timer.periodic(interval, (Timer timer) {
|
||||||
|
fn();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
static void clearInterval(Timer timer) {
|
static void clearInterval(Timer timer) {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
@ -57,7 +57,9 @@ class ReflectionCapabilities {
|
|||||||
|
|
||||||
List _convertParameter(ParameterMirror p) {
|
List _convertParameter(ParameterMirror p) {
|
||||||
var t = p.type;
|
var t = p.type;
|
||||||
var res = (!t.hasReflectedType || t.reflectedType == dynamic) ? [] : [t.reflectedType];
|
var res = (!t.hasReflectedType || t.reflectedType == dynamic)
|
||||||
|
? []
|
||||||
|
: [t.reflectedType];
|
||||||
res.addAll(p.metadata.map((m) => m.reflectee));
|
res.addAll(p.metadata.map((m) => m.reflectee));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@ import './xhr.dart' show XHR;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
class XHRImpl extends XHR {
|
class XHRImpl extends XHR {
|
||||||
Future<String> get(String url) {
|
Future<String> get(String url) {
|
||||||
|
return HttpRequest.request(url).then((HttpRequest req) => req.responseText,
|
||||||
return HttpRequest
|
onError: (_) => new Future.error('Failed to load $url'));
|
||||||
.request(url)
|
|
||||||
.then((HttpRequest req) => req.responseText,
|
|
||||||
onError: (_) => new Future.error('Failed to load $url'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
library angular2.e2e_util;
|
library angular2.e2e_util;
|
||||||
// empty as this file is node.js specific and should not be transpiled to dart
|
|
||||||
|
// empty as this file is node.js specific and should not be transpiled to dart
|
||||||
|
@ -24,24 +24,33 @@ Function fakeAsync(Function fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ([a0 = _u, a1 = _u, a2 = _u, a3 = _u, a4 = _u, a5 = _u, a6 = _u,
|
return ([a0 = _u, a1 = _u, a2 = _u, a3 = _u, a4 = _u, a5 = _u, a6 = _u,
|
||||||
a7 = _u, a8 = _u, a9 = _u]) {
|
a7 = _u, a8 = _u, a9 = _u]) {
|
||||||
// runZoned() to install a custom exception handler that re-throws
|
// runZoned() to install a custom exception handler that re-throws
|
||||||
return runZoned(() {
|
return runZoned(() {
|
||||||
new quiver.FakeAsync().run((quiver.FakeAsync async) {
|
new quiver.FakeAsync().run((quiver.FakeAsync async) {
|
||||||
try {
|
try {
|
||||||
_fakeAsync = async;
|
_fakeAsync = async;
|
||||||
List args = [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9]
|
List args = [
|
||||||
.takeWhile((a) => a != _u).toList();
|
a0,
|
||||||
return Function.apply(fn , args);
|
a1,
|
||||||
|
a2,
|
||||||
|
a3,
|
||||||
|
a4,
|
||||||
|
a5,
|
||||||
|
a6,
|
||||||
|
a7,
|
||||||
|
a8,
|
||||||
|
a9
|
||||||
|
].takeWhile((a) => a != _u).toList();
|
||||||
|
return Function.apply(fn, args);
|
||||||
} finally {
|
} finally {
|
||||||
_fakeAsync = null;
|
_fakeAsync = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
zoneSpecification: new ZoneSpecification(
|
zoneSpecification: new ZoneSpecification(
|
||||||
handleUncaughtError: (self, parent, zone, error, stackTrace)
|
handleUncaughtError: (self, parent, zone, error, stackTrace) =>
|
||||||
=> throw error
|
throw error));
|
||||||
));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
library angular2.perf_util;
|
library angular2.perf_util;
|
||||||
// empty as this file is node.js specific and should not be transpiled to dart
|
|
||||||
|
// empty as this file is node.js specific and should not be transpiled to dart
|
||||||
|
@ -190,7 +190,6 @@ class _DirectiveMetadataVisitor extends Object
|
|||||||
'$propertyName.', '$expression' /* source */);
|
'$propertyName.', '$expression' /* source */);
|
||||||
}
|
}
|
||||||
list.addAll(evaluated);
|
list.addAll(evaluated);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _populateProperties(Expression propertiesValue) {
|
void _populateProperties(Expression propertiesValue) {
|
||||||
|
@ -4,108 +4,127 @@ import 'package:angular2/test_lib.dart';
|
|||||||
import 'package:angular2/angular2.dart';
|
import 'package:angular2/angular2.dart';
|
||||||
import 'package:angular2/src/core/compiler/element_injector.dart';
|
import 'package:angular2/src/core/compiler/element_injector.dart';
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
describe('Create DirectiveMetadata', () {
|
describe('Create DirectiveMetadata', () {
|
||||||
describe('lifecycle', () {
|
describe('lifecycle', () {
|
||||||
metadata(type, annotation) => DirectiveBinding.createFromType(type, annotation).metadata;
|
metadata(type, annotation) =>
|
||||||
|
DirectiveBinding.createFromType(type, annotation).metadata;
|
||||||
|
|
||||||
describe("onChange", () {
|
describe("onChange", () {
|
||||||
it("should be true when the directive implements OnChange", () {
|
it("should be true when the directive implements OnChange", () {
|
||||||
expect(metadata(DirectiveImplementingOnChange, new Directive()).callOnChange).toBe(true);
|
expect(metadata(
|
||||||
|
DirectiveImplementingOnChange, new Directive()).callOnChange)
|
||||||
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onChange", () {
|
it("should be true when the lifecycle includes onChange", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive(lifecycle: [onChange])).callOnChange).toBe(true);
|
expect(metadata(DirectiveNoHooks,
|
||||||
|
new Directive(lifecycle: [onChange])).callOnChange).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnChange).toBe(false);
|
expect(metadata(DirectiveNoHooks, new Directive()).callOnChange)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false when empty lifecycle", () {
|
it("should be false when empty lifecycle", () {
|
||||||
expect(metadata(DirectiveImplementingOnChange, new Directive(lifecycle: [])).callOnChange).toBe(false);
|
expect(metadata(DirectiveImplementingOnChange,
|
||||||
|
new Directive(lifecycle: [])).callOnChange).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onDestroy", () {
|
describe("onDestroy", () {
|
||||||
it("should be true when the directive implements OnDestroy", () {
|
it("should be true when the directive implements OnDestroy", () {
|
||||||
expect(metadata(DirectiveImplementingOnDestroy, new Directive()).callOnDestroy).toBe(true);
|
expect(metadata(DirectiveImplementingOnDestroy,
|
||||||
|
new Directive()).callOnDestroy).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onDestroy", () {
|
it("should be true when the lifecycle includes onDestroy", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive(lifecycle: [onDestroy])).callOnDestroy).toBe(true);
|
expect(metadata(DirectiveNoHooks,
|
||||||
|
new Directive(lifecycle: [onDestroy])).callOnDestroy).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnDestroy).toBe(false);
|
expect(metadata(DirectiveNoHooks, new Directive()).callOnDestroy)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onCheck", () {
|
describe("onCheck", () {
|
||||||
it("should be true when the directive implements OnCheck", () {
|
it("should be true when the directive implements OnCheck", () {
|
||||||
expect(metadata(DirectiveImplementingOnCheck, new Directive()).callOnCheck).toBe(true);
|
expect(metadata(
|
||||||
|
DirectiveImplementingOnCheck, new Directive()).callOnCheck)
|
||||||
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onCheck", () {
|
it("should be true when the lifecycle includes onCheck", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive(lifecycle: [onCheck])).callOnCheck).toBe(true);
|
expect(metadata(DirectiveNoHooks,
|
||||||
|
new Directive(lifecycle: [onCheck])).callOnCheck).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnCheck).toBe(false);
|
expect(metadata(DirectiveNoHooks, new Directive()).callOnCheck)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onInit", () {
|
describe("onInit", () {
|
||||||
it("should be true when the directive implements OnInit", () {
|
it("should be true when the directive implements OnInit", () {
|
||||||
expect(metadata(DirectiveImplementingOnInit, new Directive()).callOnInit).toBe(true);
|
expect(metadata(
|
||||||
|
DirectiveImplementingOnInit, new Directive()).callOnInit)
|
||||||
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onInit", () {
|
it("should be true when the lifecycle includes onInit", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive(lifecycle: [onInit])).callOnInit).toBe(true);
|
expect(metadata(DirectiveNoHooks,
|
||||||
|
new Directive(lifecycle: [onInit])).callOnInit).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnInit).toBe(false);
|
expect(metadata(DirectiveNoHooks, new Directive()).callOnInit)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onAllChangesDone", () {
|
describe("onAllChangesDone", () {
|
||||||
it("should be true when the directive implements OnAllChangesDone", () {
|
it("should be true when the directive implements OnAllChangesDone", () {
|
||||||
expect(metadata(DirectiveImplementingOnAllChangesDone, new Directive()).callOnAllChangesDone).toBe(true);
|
expect(metadata(DirectiveImplementingOnAllChangesDone,
|
||||||
|
new Directive()).callOnAllChangesDone).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onAllChangesDone", () {
|
it("should be true when the lifecycle includes onAllChangesDone", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive(lifecycle: [onAllChangesDone])).callOnAllChangesDone).toBe(true);
|
expect(metadata(DirectiveNoHooks, new Directive(
|
||||||
|
lifecycle: [onAllChangesDone])).callOnAllChangesDone).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () {
|
it("should be false otherwise", () {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnAllChangesDone).toBe(false);
|
expect(metadata(
|
||||||
|
DirectiveNoHooks, new Directive()).callOnAllChangesDone)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveNoHooks {
|
class DirectiveNoHooks {}
|
||||||
}
|
|
||||||
|
|
||||||
class DirectiveImplementingOnChange implements OnChange {
|
class DirectiveImplementingOnChange implements OnChange {
|
||||||
onChange(_){}
|
onChange(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnCheck implements OnCheck {
|
class DirectiveImplementingOnCheck implements OnCheck {
|
||||||
onCheck(){}
|
onCheck() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnInit implements OnInit {
|
class DirectiveImplementingOnInit implements OnInit {
|
||||||
onInit(){}
|
onInit() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnDestroy implements OnDestroy {
|
class DirectiveImplementingOnDestroy implements OnDestroy {
|
||||||
onDestroy(){}
|
onDestroy() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectiveImplementingOnAllChangesDone implements OnAllChangesDone {
|
class DirectiveImplementingOnAllChangesDone implements OnAllChangesDone {
|
||||||
onAllChangesDone(){}
|
onAllChangesDone() {}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,18 @@ import 'package:angular2/di.dart';
|
|||||||
import 'package:angular2/src/test_lib/test_bed.dart';
|
import 'package:angular2/src/test_lib/test_bed.dart';
|
||||||
import 'package:angular2/test_lib.dart';
|
import 'package:angular2/test_lib.dart';
|
||||||
|
|
||||||
class MockException implements Error { var message; var stackTrace; }
|
class MockException implements Error {
|
||||||
class NonError { var message; }
|
var message;
|
||||||
|
var stackTrace;
|
||||||
|
}
|
||||||
|
class NonError {
|
||||||
|
var message;
|
||||||
|
}
|
||||||
|
|
||||||
void functionThatThrows() {
|
void functionThatThrows() {
|
||||||
try { throw new MockException(); }
|
try {
|
||||||
catch(e, stack) {
|
throw new MockException();
|
||||||
|
} catch (e, stack) {
|
||||||
// If we lose the stack trace the message will no longer match
|
// If we lose the stack trace the message will no longer match
|
||||||
// the first line in the stack
|
// the first line in the stack
|
||||||
e.message = stack.toString().split('\n')[0];
|
e.message = stack.toString().split('\n')[0];
|
||||||
@ -21,8 +27,9 @@ void functionThatThrows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void functionThatThrowsNonError() {
|
void functionThatThrowsNonError() {
|
||||||
try { throw new NonError(); }
|
try {
|
||||||
catch(e, stack) {
|
throw new NonError();
|
||||||
|
} catch (e, stack) {
|
||||||
// If we lose the stack trace the message will no longer match
|
// If we lose the stack trace the message will no longer match
|
||||||
// the first line in the stack
|
// the first line in the stack
|
||||||
e.message = stack.toString().split('\n')[0];
|
e.message = stack.toString().split('\n')[0];
|
||||||
@ -32,12 +39,13 @@ void functionThatThrowsNonError() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
describe('TypeLiteral', () {
|
describe('TypeLiteral', () {
|
||||||
it('should publish via appInjector',
|
it('should publish via appInjector', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '<type-literal-component></type-literal-component>',
|
template: '<type-literal-component></type-literal-component>',
|
||||||
directives: [TypeLiteralComponent]
|
directives: [TypeLiteralComponent]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).then((view) {
|
tb.createView(Dummy).then((view) {
|
||||||
view.detectChanges();
|
view.detectChanges();
|
||||||
@ -48,12 +56,13 @@ main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Error handling', () {
|
describe('Error handling', () {
|
||||||
it('should preserve Error stack traces thrown from components',
|
it('should preserve Error stack traces thrown from components', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '<throwing-component></throwing-component>',
|
template: '<throwing-component></throwing-component>',
|
||||||
directives: [ThrowingComponent]
|
directives: [ThrowingComponent]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).catchError((e, stack) {
|
tb.createView(Dummy).catchError((e, stack) {
|
||||||
expect(stack.toString().split('\n')[0]).toEqual(e.message);
|
expect(stack.toString().split('\n')[0]).toEqual(e.message);
|
||||||
@ -61,12 +70,13 @@ main() {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should preserve non-Error stack traces thrown from components',
|
it('should preserve non-Error stack traces thrown from components', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '<throwing-component2></throwing-component2>',
|
template: '<throwing-component2></throwing-component2>',
|
||||||
directives: [ThrowingComponent2]
|
directives: [ThrowingComponent2]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).catchError((e, stack) {
|
tb.createView(Dummy).catchError((e, stack) {
|
||||||
expect(stack.toString().split('\n')[0]).toEqual(e.message);
|
expect(stack.toString().split('\n')[0]).toEqual(e.message);
|
||||||
@ -76,12 +86,13 @@ main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Property access', () {
|
describe('Property access', () {
|
||||||
it('should distinguish between map and property access',
|
it('should distinguish between map and property access', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '<property-access></property-access>',
|
template: '<property-access></property-access>',
|
||||||
directives: [PropertyAccess]
|
directives: [PropertyAccess]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).then((view) {
|
tb.createView(Dummy).then((view) {
|
||||||
view.detectChanges();
|
view.detectChanges();
|
||||||
@ -90,12 +101,13 @@ main() {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not fallback on map access if property missing',
|
it('should not fallback on map access if property missing', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '<no-property-access></no-property-access>',
|
template: '<no-property-access></no-property-access>',
|
||||||
directives: [NoPropertyAccess]
|
directives: [NoPropertyAccess]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).then((view) {
|
tb.createView(Dummy).then((view) {
|
||||||
expect(() => view.detectChanges())
|
expect(() => view.detectChanges())
|
||||||
@ -106,12 +118,13 @@ main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('OnChange', () {
|
describe('OnChange', () {
|
||||||
it('should be notified of changes',
|
it('should be notified of changes', inject([
|
||||||
inject([TestBed, AsyncTestCompleter], (tb, async) {
|
TestBed,
|
||||||
|
AsyncTestCompleter
|
||||||
|
], (tb, async) {
|
||||||
tb.overrideView(Dummy, new View(
|
tb.overrideView(Dummy, new View(
|
||||||
template: '''<on-change [prop]="'hello'"></on-change>''',
|
template: '''<on-change [prop]="'hello'"></on-change>''',
|
||||||
directives: [OnChangeComponent]
|
directives: [OnChangeComponent]));
|
||||||
));
|
|
||||||
|
|
||||||
tb.createView(Dummy).then((view) {
|
tb.createView(Dummy).then((view) {
|
||||||
view.detectChanges();
|
view.detectChanges();
|
||||||
@ -128,25 +141,19 @@ main() {
|
|||||||
class Dummy {}
|
class Dummy {}
|
||||||
|
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'type-literal-component',
|
selector: 'type-literal-component',
|
||||||
appInjector: const [
|
appInjector: const [
|
||||||
const Binding(
|
const Binding(const TypeLiteral<List<String>>(),
|
||||||
const TypeLiteral<List<String>>(),
|
toValue: const <String>['Hello', 'World'])
|
||||||
toValue: const <String>['Hello', 'World'])
|
])
|
||||||
]
|
@View(template: '{{list}}')
|
||||||
)
|
|
||||||
@View(
|
|
||||||
template: '{{list}}'
|
|
||||||
)
|
|
||||||
class TypeLiteralComponent {
|
class TypeLiteralComponent {
|
||||||
final List<String> list;
|
final List<String> list;
|
||||||
|
|
||||||
TypeLiteralComponent(this.list);
|
TypeLiteralComponent(this.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'throwing-component')
|
||||||
selector: 'throwing-component'
|
|
||||||
)
|
|
||||||
@View(template: '')
|
@View(template: '')
|
||||||
class ThrowingComponent {
|
class ThrowingComponent {
|
||||||
ThrowingComponent() {
|
ThrowingComponent() {
|
||||||
@ -154,9 +161,7 @@ class ThrowingComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'throwing-component2')
|
||||||
selector: 'throwing-component2'
|
|
||||||
)
|
|
||||||
@View(template: '')
|
@View(template: '')
|
||||||
class ThrowingComponent2 {
|
class ThrowingComponent2 {
|
||||||
ThrowingComponent2() {
|
ThrowingComponent2() {
|
||||||
@ -168,7 +173,7 @@ class ThrowingComponent2 {
|
|||||||
class PropModel implements Map {
|
class PropModel implements Map {
|
||||||
final String foo = 'foo-prop';
|
final String foo = 'foo-prop';
|
||||||
|
|
||||||
operator[](_) => 'foo-map';
|
operator [](_) => 'foo-map';
|
||||||
|
|
||||||
noSuchMethod(_) {
|
noSuchMethod(_) {
|
||||||
throw 'property not found';
|
throw 'property not found';
|
||||||
@ -187,12 +192,9 @@ class NoPropertyAccess {
|
|||||||
final model = new PropModel();
|
final model = new PropModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'on-change',
|
||||||
selector: 'on-change',
|
// TODO: needed because of https://github.com/angular/angular/issues/2120
|
||||||
// TODO: needed because of https://github.com/angular/angular/issues/2120
|
lifecycle: const [onChange], properties: const ['prop'])
|
||||||
lifecycle: const [onChange],
|
|
||||||
properties: const ['prop']
|
|
||||||
)
|
|
||||||
@View(template: '')
|
@View(template: '')
|
||||||
class OnChangeComponent implements OnChange {
|
class OnChangeComponent implements OnChange {
|
||||||
Map changes;
|
Map changes;
|
||||||
|
@ -7,10 +7,8 @@ import 'package:angular2/di.dart';
|
|||||||
main() {
|
main() {
|
||||||
describe('Injector', () {
|
describe('Injector', () {
|
||||||
it('should support TypeLiteral', () {
|
it('should support TypeLiteral', () {
|
||||||
var i = Injector.resolveAndCreate([
|
var i = Injector.resolveAndCreate(
|
||||||
bind(new TypeLiteral<List<int>>()).toValue([1, 2, 3]),
|
[bind(new TypeLiteral<List<int>>()).toValue([1, 2, 3]), Foo,]);
|
||||||
Foo,
|
|
||||||
]);
|
|
||||||
expect(i.get(Foo).value).toEqual([1, 2, 3]);
|
expect(i.get(Foo).value).toEqual([1, 2, 3]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,12 +4,18 @@ library angular2.test.facade.async_dart_spec;
|
|||||||
import 'package:angular2/test_lib.dart';
|
import 'package:angular2/test_lib.dart';
|
||||||
import 'package:angular2/src/facade/async.dart';
|
import 'package:angular2/src/facade/async.dart';
|
||||||
|
|
||||||
class MockException implements Error { var message; var stackTrace; }
|
class MockException implements Error {
|
||||||
class NonError { var message; }
|
var message;
|
||||||
|
var stackTrace;
|
||||||
|
}
|
||||||
|
class NonError {
|
||||||
|
var message;
|
||||||
|
}
|
||||||
|
|
||||||
void functionThatThrows() {
|
void functionThatThrows() {
|
||||||
try { throw new MockException(); }
|
try {
|
||||||
catch(e, stack) {
|
throw new MockException();
|
||||||
|
} catch (e, stack) {
|
||||||
// If we lose the stack trace the message will no longer match
|
// If we lose the stack trace the message will no longer match
|
||||||
// the first line in the stack
|
// the first line in the stack
|
||||||
e.message = stack.toString().split('\n')[0];
|
e.message = stack.toString().split('\n')[0];
|
||||||
@ -19,8 +25,9 @@ void functionThatThrows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void functionThatThrowsNonError() {
|
void functionThatThrowsNonError() {
|
||||||
try { throw new NonError(); }
|
try {
|
||||||
catch(e, stack) {
|
throw new NonError();
|
||||||
|
} catch (e, stack) {
|
||||||
// If we lose the stack trace the message will no longer match
|
// If we lose the stack trace the message will no longer match
|
||||||
// the first line in the stack
|
// the first line in the stack
|
||||||
e.message = stack.toString().split('\n')[0];
|
e.message = stack.toString().split('\n')[0];
|
||||||
@ -39,62 +46,55 @@ void expectFunctionThatThrowsWithStackTrace(
|
|||||||
main() {
|
main() {
|
||||||
describe('async facade', () {
|
describe('async facade', () {
|
||||||
describe('Completer', () {
|
describe('Completer', () {
|
||||||
|
it('should preserve Error stack traces', inject([AsyncTestCompleter],
|
||||||
it('should preserve Error stack traces',
|
(async) {
|
||||||
inject([AsyncTestCompleter], (async) {
|
|
||||||
var c = PromiseWrapper.completer();
|
var c = PromiseWrapper.completer();
|
||||||
|
|
||||||
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
functionThatThrows();
|
functionThatThrows();
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
c.reject(e, null);
|
c.reject(e, null);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should preserve error stack traces for non-Errors',
|
it('should preserve error stack traces for non-Errors', inject(
|
||||||
inject([AsyncTestCompleter], (async) {
|
[AsyncTestCompleter], (async) {
|
||||||
var c = PromiseWrapper.completer();
|
var c = PromiseWrapper.completer();
|
||||||
|
|
||||||
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
functionThatThrowsNonError();
|
functionThatThrowsNonError();
|
||||||
} catch(e, s) {
|
} catch (e, s) {
|
||||||
c.reject(e, s);
|
c.reject(e, s);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('PromiseWrapper', () {
|
describe('PromiseWrapper', () {
|
||||||
|
|
||||||
describe('reject', () {
|
describe('reject', () {
|
||||||
|
it('should preserve Error stack traces', inject([AsyncTestCompleter],
|
||||||
it('should preserve Error stack traces',
|
(async) {
|
||||||
inject([AsyncTestCompleter], (async) {
|
|
||||||
try {
|
try {
|
||||||
functionThatThrows();
|
functionThatThrows();
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
var rejectedFuture = PromiseWrapper.reject(e, null);
|
var rejectedFuture = PromiseWrapper.reject(e, null);
|
||||||
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should preserve stack traces for non-Errors',
|
it('should preserve stack traces for non-Errors', inject(
|
||||||
inject([AsyncTestCompleter], (async) {
|
[AsyncTestCompleter], (async) {
|
||||||
try {
|
try {
|
||||||
functionThatThrowsNonError();
|
functionThatThrowsNonError();
|
||||||
} catch(e, s) {
|
} catch (e, s) {
|
||||||
var rejectedFuture = PromiseWrapper.reject(e, s);
|
var rejectedFuture = PromiseWrapper.reject(e, s);
|
||||||
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,4 @@ ClassDecorator classDecorator(value) {
|
|||||||
|
|
||||||
ParamDecorator paramDecorator(value) {
|
ParamDecorator paramDecorator(value) {
|
||||||
return new ParamDecorator(value);
|
return new ParamDecorator(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user