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