| Index: third_party/pkg/angular/lib/mock/test_injection.dart
|
| diff --git a/third_party/pkg/angular/lib/mock/test_injection.dart b/third_party/pkg/angular/lib/mock/test_injection.dart
|
| index ae1542d34ea327e55f236ee524904382ec7f23c2..2ca2b6c2c947446e96d14ff66b6c4e95734d475f 100644
|
| --- a/third_party/pkg/angular/lib/mock/test_injection.dart
|
| +++ b/third_party/pkg/angular/lib/mock/test_injection.dart
|
| @@ -5,8 +5,9 @@ _SpecInjector _currentSpecInjector = null;
|
| class _SpecInjector {
|
| DynamicInjector moduleInjector;
|
| DynamicInjector injector;
|
| - List<Module> modules = [];
|
| - List<Function> initFns = [];
|
| + dynamic injectiorCreateLocation;
|
| + final modules = <Module>[];
|
| + final initFns = <Function>[];
|
|
|
| _SpecInjector() {
|
| var moduleModule = new Module()
|
| @@ -23,12 +24,13 @@ class _SpecInjector {
|
| }
|
|
|
| module(fnOrModule, [declarationStack]) {
|
| + if (injectiorCreateLocation != null) {
|
| + throw "Injector already created at:\n$injectiorCreateLocation";
|
| + }
|
| try {
|
| if (fnOrModule is Function) {
|
| var initFn = moduleInjector.invoke(fnOrModule);
|
| - if (initFn is Function) {
|
| - initFns.add(initFn);
|
| - }
|
| + if (initFn is Function) initFns.add(initFn);
|
| } else if (fnOrModule is Module) {
|
| addModule(fnOrModule);
|
| } else {
|
| @@ -42,6 +44,7 @@ class _SpecInjector {
|
| inject(Function fn, [declarationStack]) {
|
| try {
|
| if (injector == null) {
|
| + injectiorCreateLocation = declarationStack;
|
| injector = new DynamicInjector(modules: modules); // Implicit injection is disabled.
|
| initFns.forEach((fn) {
|
| injector.invoke(fn);
|
| @@ -55,6 +58,7 @@ class _SpecInjector {
|
|
|
| reset() {
|
| injector = null;
|
| + injectiorCreateLocation = null;
|
| }
|
| }
|
|
|
| @@ -81,12 +85,12 @@ class _SpecInjector {
|
| *
|
| */
|
| inject(Function fn) {
|
| - try { throw ''; } catch (e, stack) {
|
| - if (_currentSpecInjector == null ) {
|
| - return () => _currentSpecInjector.inject(fn, stack);
|
| - } else {
|
| - return _currentSpecInjector.inject(fn, stack);
|
| - }
|
| + try {
|
| + throw '';
|
| + } catch (e, stack) {
|
| + return _currentSpecInjector == null
|
| + ? () => _currentSpecInjector.inject(fn, stack)
|
| + : _currentSpecInjector.inject(fn, stack);
|
| }
|
| }
|
|
|
| @@ -108,27 +112,28 @@ inject(Function fn) {
|
| * });
|
| */
|
| module(fnOrModule) {
|
| - try { throw ''; } catch(e, stack) {
|
| - if (_currentSpecInjector == null ) {
|
| - return () => _currentSpecInjector.module(fnOrModule, stack);
|
| - } else {
|
| - return _currentSpecInjector.module(fnOrModule, stack);
|
| - }
|
| + try {
|
| + throw '';
|
| + } catch(e, stack) {
|
| + return _currentSpecInjector == null
|
| + ? () => _currentSpecInjector.module(fnOrModule, stack)
|
| + : _currentSpecInjector.module(fnOrModule, stack);
|
| }
|
| }
|
|
|
| /**
|
| * Call this method in your test harness [setUp] method to setup the injector.
|
| */
|
| -setUpInjector() {
|
| +void setUpInjector() {
|
| _currentSpecInjector = new _SpecInjector();
|
| _currentSpecInjector.module((Module m) {
|
| - m.install(new AngularModule());
|
| - m.install(new AngularMockModule());
|
| + m..install(new AngularModule())..install(new AngularMockModule());
|
| });
|
| }
|
|
|
| /**
|
| * Call this method in your test harness [tearDown] method to cleanup the injector.
|
| */
|
| -tearDownInjector() => _currentSpecInjector = null;
|
| +void tearDownInjector() {
|
| + _currentSpecInjector = null;
|
| +}
|
|
|