Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: third_party/pkg/di/test/main.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 @Injectables(const [ 1 @Injectables(const [
2 ClassOne, 2 ClassOne,
3 CircularA, 3 CircularA,
4 CircularB, 4 CircularB,
5 MultipleConstructors, 5 MultipleConstructors,
6 NumDependency, 6 NumDependency,
7 IntDependency, 7 IntDependency,
8 DoubleDependency, 8 DoubleDependency,
9 BoolDependency, 9 BoolDependency,
10 StringDependency 10 StringDependency
11 ]) 11 ])
12 library di.tests; 12 library di.tests;
13 13
14 import 'fixed-unittest.dart'; 14 import 'fixed-unittest.dart';
15 import 'package:di/di.dart'; 15 import 'package:di/di.dart';
16 import 'package:di/dynamic_injector.dart'; 16 import 'package:di/dynamic_injector.dart';
17 import 'package:di/static_injector.dart'; 17 import 'package:di/static_injector.dart';
18 import 'package:di/annotations.dart'; 18 import 'package:di/annotations.dart';
19 19
20 import 'test_annotations.dart';
21 // Generated file. Run ../test_tf_gen.sh. 20 // Generated file. Run ../test_tf_gen.sh.
22 import 'type_factories_gen.dart' as type_factories_gen; 21 import 'type_factories_gen.dart' as type_factories_gen;
23 22
24 /** 23 /**
25 * Annotation used to mark classes for which static type factory must be 24 * Annotation used to mark classes for which static type factory must be
26 * generated. For testing purposes not all classes are marked with this 25 * generated. For testing purposes not all classes are marked with this
27 * annotation, some classes are included in @Injectables at the top. 26 * annotation, some classes are included in @Injectables at the top.
28 */ 27 */
29 class InjectableTest { 28 class Injectable {
30 const InjectableTest(); 29 const Injectable();
31 } 30 }
32 31
33 // just some classes for testing 32 // just some classes for testing
34 @InjectableTest() 33 @Injectable()
35 class Engine { 34 class Engine {
36 final String id = 'v8-id'; 35 final String id = 'v8-id';
37 } 36 }
38 37
39 @Injectable() 38 @Injectable()
40 class MockEngine implements Engine { 39 class MockEngine implements Engine {
41 final String id = 'mock-id'; 40 final String id = 'mock-id';
42 } 41 }
43 42
44 @InjectableTest() 43 @Injectable()
45 class MockEngine2 implements Engine { 44 class MockEngine2 implements Engine {
46 String id = 'mock-id-2'; 45 String id = 'mock-id-2';
47 } 46 }
48 47
49 class HiddenConstructor { 48 class HiddenConstructor {
50 HiddenConstructor._(); 49 HiddenConstructor._();
51 } 50 }
52 51
53 @InjectableTest() 52 @Injectable()
54 class TurboEngine implements Engine {
55 String id = 'turbo-engine-id';
56 }
57
58 @InjectableTest()
59 class BrokenOldEngine implements Engine {
60 String id = 'broken-old-engine-id';
61 }
62
63 @InjectableTest()
64 class Car { 53 class Car {
65 Engine engine; 54 Engine engine;
66 Injector injector; 55 Injector injector;
67 56
68 Car(this.engine, this.injector); 57 Car(this.engine, this.injector);
69 } 58 }
70 59
71 class Lemon { 60 class Lemon {
72 final engine; 61 final engine;
73 final Injector injector; 62 final Injector injector;
74 63
75 Lemon(this.engine, this.injector); 64 Lemon(this.engine, this.injector);
76 } 65 }
77 66
78 @InjectableTest()
79 class Porsche {
80 Engine engine;
81 Injector injector;
82
83 Porsche(@Turbo() this.engine, this.injector);
84 }
85
86 class NumDependency { 67 class NumDependency {
87 NumDependency(num value) {} 68 NumDependency(num value) {}
88 } 69 }
89 70
90 class IntDependency { 71 class IntDependency {
91 IntDependency(int value) {} 72 IntDependency(int value) {}
92 } 73 }
93 74
94 class DoubleDependency { 75 class DoubleDependency {
95 DoubleDependency(double value) {} 76 DoubleDependency(double value) {}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 111
131 class InterfaceOne { 112 class InterfaceOne {
132 } 113 }
133 114
134 class ClassOne implements InterfaceOne { 115 class ClassOne implements InterfaceOne {
135 ClassOne(Log log) { 116 ClassOne(Log log) {
136 log.add('ClassOne'); 117 log.add('ClassOne');
137 } 118 }
138 } 119 }
139 120
140 @InjectableTest() 121 @Injectable()
141 class ParameterizedType<T1, T2> { 122 class ParameterizedType<T1, T2> {
142 ParameterizedType(); 123 ParameterizedType();
143 } 124 }
144 125
145 @InjectableTest() 126 @Injectable()
146 class ParameterizedDependency { 127 class ParameterizedDependency {
147 final ParameterizedType<bool, int> _p; 128 final ParameterizedType<bool, int> _p;
148 ParameterizedDependency(this._p); 129 ParameterizedDependency(this._p);
149 } 130 }
150 131
151 @InjectableTest() 132 @Injectable()
152 class GenericParameterizedDependency { 133 class GenericParameterizedDependency {
153 final ParameterizedType _p; 134 final ParameterizedType _p;
154 GenericParameterizedDependency(this._p); 135 GenericParameterizedDependency(this._p);
155 } 136 }
156 137
157 @InjectableTest() 138 @Injectable()
158 class Log { 139 class Log {
159 var log = []; 140 var log = [];
160 141
161 add(String message) => log.add(message); 142 add(String message) => log.add(message);
162 } 143 }
163 144
164 @InjectableTest()
165 class AnnotatedPrimitiveDependency {
166 String strValue;
167 AnnotatedPrimitiveDependency(@Turbo() this.strValue);
168 }
169
170 class EmulatedMockEngineFactory { 145 class EmulatedMockEngineFactory {
171 call(Injector i) => new MockEngine(); 146 call(Injector i) => new MockEngine();
172 } 147 }
173 148
174 bool throwOnceShouldThrow = true;
175 @InjectableTest()
176 class ThrowOnce {
177 ThrowOnce() {
178 if (throwOnceShouldThrow) {
179 throwOnceShouldThrow = false;
180 throw ["ThrowOnce"];
181 }
182 }
183 }
184
185 void main() { 149 void main() {
186 createInjectorSpec('DynamicInjector', 150 createInjectorSpec('DynamicInjector',
187 (modules, [name]) => new DynamicInjector(modules: modules, name: name)); 151 (modules, [name]) => new DynamicInjector(modules: modules, name: name));
188 152
189 createInjectorSpec('StaticInjector', 153 createInjectorSpec('StaticInjector',
190 (modules, [name]) => new StaticInjector(modules: modules, name: name, 154 (modules, [name]) => new StaticInjector(modules: modules, name: name,
191 typeFactories: type_factories_gen.typeFactories)); 155 typeFactories: type_factories_gen.typeFactories));
192 156
193 dynamicInjectorTest(); 157 dynamicInjectorTest();
194 staticInjectorTest(); 158 staticInjectorTest();
195 createKeySpec();
196 } 159 }
197 160
198 typedef Injector InjectorFactory(List<Module> modules, [String name]); 161 typedef Injector InjectorFactory(List<Module> modules, [String name]);
199 162
200 createInjectorSpec(String injectorName, InjectorFactory injectorFactory) { 163 createInjectorSpec(String injectorName, InjectorFactory injectorFactory) {
201 164
202 describe(injectorName, () { 165 describe(injectorName, () {
203 166
204 it('should instantiate a type', () { 167 it('should instantiate a type', () {
205 var injector = injectorFactory([new Module()..type(Engine)]); 168 var injector = injectorFactory([new Module()..type(Engine)]);
206 var instance = injector.get(Engine); 169 var instance = injector.get(Engine);
207 170
208 expect(instance, instanceOf(Engine)); 171 expect(instance, instanceOf(Engine));
209 expect(instance.id, toEqual('v8-id')); 172 expect(instance.id, toEqual('v8-id'));
210 }); 173 });
211 174
212 it('should instantiate an annotated type', () {
213 var injector = injectorFactory([new Module()
214 ..type(Engine, withAnnotation: Turbo, implementedBy: TurboEngine)
215 ..value(Car, new Engine())
216 ]);
217 var instance = injector.getByKey(new Key(Engine, Turbo));
218
219 expect(instance, instanceOf(TurboEngine));
220 expect(instance.id, toEqual('turbo-engine-id'));
221 });
222
223 it('should fail if no binding is found', () { 175 it('should fail if no binding is found', () {
224 var injector = injectorFactory([]); 176 var injector = injectorFactory([]);
225 expect(() { 177 expect(() {
226 injector.get(Engine); 178 injector.get(Engine);
227 }, toThrow(NoProviderError, 'No provider found for Engine! ' 179 }, toThrow(NoProviderError, 'No provider found for Engine! '
228 '(resolving Engine)')); 180 '(resolving Engine)'));
229 }); 181 });
230 182
231 183
232 it('should resolve basic dependencies', () { 184 it('should resolve basic dependencies', () {
233 var injector = injectorFactory([new Module()..type(Car)..type(Engine)]); 185 var injector = injectorFactory([new Module()..type(Car)..type(Engine)]);
234 var instance = injector.get(Car); 186 var instance = injector.get(Car);
235 187
236 expect(instance, instanceOf(Car)); 188 expect(instance, instanceOf(Car));
237 expect(instance.engine.id, toEqual('v8-id')); 189 expect(instance.engine.id, toEqual('v8-id'));
238 }); 190 });
239 191
240 it('should resolve complex dependencies', () {
241 var injector = injectorFactory([new Module()
242 ..type(Porsche)
243 ..type(TurboEngine)
244 ..type(Engine, withAnnotation: Turbo, implementedBy: TurboEngine)
245 ]);
246 var instance = injector.get(Porsche);
247
248 expect(instance, instanceOf(Porsche));
249 expect(instance.engine.id, toEqual('turbo-engine-id'));
250 });
251
252 it('should resolve annotated primitive type', () {
253 var injector = injectorFactory([new Module()
254 ..type(AnnotatedPrimitiveDependency)
255 ..value(String, 'Worked!', withAnnotation: Turbo)
256 ]);
257 var instance = injector.get(AnnotatedPrimitiveDependency);
258
259 expect(instance, instanceOf(AnnotatedPrimitiveDependency));
260 expect(instance.strValue, toEqual('Worked!'));
261 });
262 192
263 it('should inject generic parameterized types', () { 193 it('should inject generic parameterized types', () {
264 var injector = injectorFactory([new Module() 194 var injector = injectorFactory([new Module()
265 ..type(ParameterizedType) 195 ..type(ParameterizedType)
266 ..type(GenericParameterizedDependency) 196 ..type(GenericParameterizedDependency)
267 ]); 197 ]);
268 expect(injector.get(GenericParameterizedDependency), 198 expect(injector.get(GenericParameterizedDependency),
269 new isInstanceOf<GenericParameterizedDependency>()); 199 new isInstanceOf<GenericParameterizedDependency>());
270 }); 200 });
271 201
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 '(resolving BoolDependency -> bool)')); 314 '(resolving BoolDependency -> bool)'));
385 315
386 expect(() { 316 expect(() {
387 injector.get(StringDependency); 317 injector.get(StringDependency);
388 }, toThrow(NoProviderError, 'Cannot inject a primitive type of String! ' 318 }, toThrow(NoProviderError, 'Cannot inject a primitive type of String! '
389 '(resolving StringDependency -> String)')); 319 '(resolving StringDependency -> String)'));
390 }); 320 });
391 321
392 322
393 it('should throw an exception when circular dependency', () { 323 it('should throw an exception when circular dependency', () {
394 var injector = injectorFactory([new Module()..type(CircularA) 324 var injector = injectorFactory([new Module()..type(CircularA)..type(Circul arB)]);
395 ..type(CircularB)]);
396 325
397 expect(() { 326 expect(() {
398 injector.get(CircularA); 327 injector.get(CircularA);
399 }, toThrow(CircularDependencyError, 'Cannot resolve a circular ' 328 }, toThrow(CircularDependencyError, 'Cannot resolve a circular dependency! '
400 'dependency! (resolving CircularA -> CircularB -> CircularA')); 329 '(resolving CircularA -> '
401 }); 330 'CircularB -> CircularA)'));
402
403 it('should throw an exception when circular dependency in factory', () {
404 var injector = injectorFactory([new Module()
405 ..factory(CircularA, (i) => i.get(CircularA))
406 ]);
407
408 expect(() {
409 injector.get(CircularA);
410 }, toThrow(CircularDependencyError, 'Cannot resolve a '
411 'circular dependency! (resolving CircularA -> CircularA'));
412 }); 331 });
413 332
414 333
415 it('should recover from errors', () {
416 var injector = injectorFactory([new Module()..type(ThrowOnce)]);
417 throwOnceShouldThrow = true;
418
419 var caught = false;
420 try {
421 injector.get(ThrowOnce);
422 } catch (e, s) {
423 caught = true;
424 expect(injector.get(ThrowOnce), not(toEqual(null)));
425 }
426 expect(caught, toEqual(true));
427 });
428
429
430 it('should provide the injector as Injector', () { 334 it('should provide the injector as Injector', () {
431 var injector = injectorFactory([]); 335 var injector = injectorFactory([]);
432 336
433 expect(injector.get(Injector), toBe(injector)); 337 expect(injector.get(Injector), toBe(injector));
434 }); 338 });
435 339
436 340
437 it('should inject a typedef', () { 341 it('should inject a typedef', () {
438 var module = new Module()..value(CompareInt, compareIntAsc); 342 var module = new Module()..value(CompareInt, compareIntAsc);
439 343
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 376
473 expect(abcFromParent.id, toEqual('v8-id')); 377 expect(abcFromParent.id, toEqual('v8-id'));
474 expect(abcFromChild.id, toEqual('mock-id')); 378 expect(abcFromChild.id, toEqual('mock-id'));
475 }); 379 });
476 380
477 381
478 it('should enumerate across children', () { 382 it('should enumerate across children', () {
479 var parent = injectorFactory([new Module()..type(Engine)]); 383 var parent = injectorFactory([new Module()..type(Engine)]);
480 var child = parent.createChild([new Module()..type(MockEngine)]); 384 var child = parent.createChild([new Module()..type(MockEngine)]);
481 385
482 expect(parent.types, unorderedEquals(new Set.from( 386 expect(parent.types, unorderedEquals(new Set.from([Engine, Injector])));
483 [Engine, Injector]))); 387 expect(child.types, unorderedEquals(new Set.from([Engine, MockEngine, Inje ctor])));
484 expect(child.types, unorderedEquals(new Set.from(
485 [Engine, MockEngine, Injector])));
486 }); 388 });
487 389
488 390
489 it('should inject instance from parent if not provided in child', () { 391 it('should inject instance from parent if not provided in child', () {
490 var module = new Module()..type(Car); 392 var module = new Module()..type(Car);
491 393
492 var parent = injectorFactory([new Module()..type(Car)..type(Engine)]); 394 var parent = injectorFactory([new Module()..type(Car)..type(Engine)]);
493 var child = parent.createChild([module]); 395 var child = parent.createChild([module]);
494 396
495 var complexFromParent = parent.get(Car); 397 var complexFromParent = parent.get(Car);
(...skipping 20 matching lines...) Expand all
516 expect(complexFromChild, toBe(complexFromParent)); 418 expect(complexFromChild, toBe(complexFromParent));
517 expect(complexFromChild.engine, toBe(abcFromParent)); 419 expect(complexFromChild.engine, toBe(abcFromParent));
518 expect(complexFromChild.engine, not(toBe(abcFromChild))); 420 expect(complexFromChild.engine, not(toBe(abcFromChild)));
519 }); 421 });
520 422
521 423
522 it('should force new instance in child even if already instantiated in paren t', () { 424 it('should force new instance in child even if already instantiated in paren t', () {
523 var parent = injectorFactory([new Module()..type(Engine)]); 425 var parent = injectorFactory([new Module()..type(Engine)]);
524 var abcAlreadyInParent = parent.get(Engine); 426 var abcAlreadyInParent = parent.get(Engine);
525 427
526 var child = parent.createChild([], forceNewInstances: [new Key(Engine)]); 428 var child = parent.createChild([], forceNewInstances: [Engine]);
527 var abcFromChild = child.get(Engine); 429 var abcFromChild = child.get(Engine);
528 430
529 expect(abcFromChild, not(toBe(abcAlreadyInParent))); 431 expect(abcFromChild, not(toBe(abcAlreadyInParent)));
530 }); 432 });
531 433
532 434
533 it('should force new instance in child using provider from grand parent', () { 435 it('should force new instance in child using provider from grand parent', () {
534 var module = new Module()..type(Engine, implementedBy: MockEngine); 436 var module = new Module()..type(Engine, implementedBy: MockEngine);
535 437
536 var grandParent = injectorFactory([module]); 438 var grandParent = injectorFactory([module]);
537 var parent = grandParent.createChild([]); 439 var parent = grandParent.createChild([]);
538 var child = parent.createChild([], forceNewInstances: [new Key(Engine)]); 440 var child = parent.createChild([], forceNewInstances: [Engine]);
539 441
540 var abcFromGrandParent = grandParent.get(Engine); 442 var abcFromGrandParent = grandParent.get(Engine);
541 var abcFromChild = child.get(Engine); 443 var abcFromChild = child.get(Engine);
542 444
543 expect(abcFromChild.id, toEqual(('mock-id'))); 445 expect(abcFromChild.id, toEqual(('mock-id')));
544 expect(abcFromChild, not(toBe(abcFromGrandParent))); 446 expect(abcFromChild, not(toBe(abcFromGrandParent)));
545 }); 447 });
546 448
547 449
548 it('should provide child injector as Injector', () { 450 it('should provide child injector as Injector', () {
(...skipping 11 matching lines...) Expand all
560 462
561 463
562 it('should set the child injector name', () { 464 it('should set the child injector name', () {
563 var injector = injectorFactory([], 'foo'); 465 var injector = injectorFactory([], 'foo');
564 var childInjector = injector.createChild(null, name: 'bar'); 466 var childInjector = injector.createChild(null, name: 'bar');
565 expect(childInjector.name, 'bar'); 467 expect(childInjector.name, 'bar');
566 }); 468 });
567 469
568 470
569 it('should instantiate class only once (Issue #18)', () { 471 it('should instantiate class only once (Issue #18)', () {
570 var rootInjector = injectorFactory([]); 472 var injector = injectorFactory([
571 var injector = rootInjector.createChild([
572 new Module() 473 new Module()
573 ..type(Log) 474 ..type(Log)
574 ..type(ClassOne) 475 ..type(ClassOne)
575 ..factory(InterfaceOne, (i) => i.get(ClassOne)) 476 ..factory(InterfaceOne, (i) => i.get(ClassOne))
576 ]); 477 ]);
577 478
578 expect(injector.get(InterfaceOne), same(injector.get(ClassOne))); 479 expect(injector.get(InterfaceOne), same(injector.get(ClassOne)));
579 expect(injector.get(Log).log.join(' '), 'ClassOne'); 480 expect(injector.get(Log).log.join(' '), 'ClassOne');
580 }); 481 });
581 482
582 483
484 describe('creation strategy', () {
485
486 it('should get called for instance creation', () {
487
488 List creationLog = [];
489 dynamic creation(Injector requesting, Injector defining, factory) {
490 creationLog.add([requesting, defining]);
491 return factory();
492 }
493
494 var parentModule = new Module()
495 ..type(Engine, implementedBy: MockEngine, creation: creation)
496 ..type(Car, creation: creation);
497
498 var parentInjector = injectorFactory([parentModule]);
499 var childInjector = parentInjector.createChild([]);
500 childInjector.get(Car);
501 expect(creationLog, [
502 [childInjector, parentInjector],
503 [childInjector, parentInjector]
504 ]);
505 });
506
507 it('should be able to prevent instantiation', () {
508
509 List creationLog = [];
510 dynamic creation(Injector requesting, Injector defining, factory) {
511 throw 'not allowing';
512 }
513
514 var module = new Module()
515 ..type(Engine, implementedBy: MockEngine, creation: creation);
516 var injector = injectorFactory([module]);
517 expect(() {
518 injector.get(Engine);
519 }, throwsA('not allowing'));
520 });
521 });
522
523
583 describe('visiblity', () { 524 describe('visiblity', () {
584 525
585 it('should hide instances', () { 526 it('should hide instances', () {
586 527
587 var rootMock = new MockEngine(); 528 var rootMock = new MockEngine();
588 var childMock = new MockEngine(); 529 var childMock = new MockEngine();
589 530
590 var parentModule = new Module() 531 var parentModule = new Module()
591 ..value(Engine, rootMock); 532 ..value(Engine, rootMock);
592 var childModule = new Module() 533 var childModule = new Module()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 var module = new Module()..type(HiddenConstructor); 577 var module = new Module()..type(HiddenConstructor);
637 var injector = new DynamicInjector(modules: [module]); 578 var injector = new DynamicInjector(modules: [module]);
638 579
639 expect(() { 580 expect(() {
640 injector.get(HiddenConstructor); 581 injector.get(HiddenConstructor);
641 }, toThrow(NoProviderError, startsWith('Unable to find default ' 582 }, toThrow(NoProviderError, startsWith('Unable to find default '
642 'constructor for HiddenConstructor. Make sure class has a ' 583 'constructor for HiddenConstructor. Make sure class has a '
643 'default constructor.'))); 584 'default constructor.')));
644 }); 585 });
645 586
646 it('should inject parameters into function and invoke it', () {
647 var module = new Module()
648 ..type(Engine);
649 var id;
650 var injector = new DynamicInjector(modules: [module]);
651 injector.invoke((Engine e) => id = e.id);
652 expect(id, equals('v8-id'));
653 });
654
655 it('should inject annotated parameters into function and invoke it', () {
656 var module = new Module()
657 ..type(Engine, withAnnotation: Turbo, implementedBy: TurboEngine);
658 var id;
659 var injector = new DynamicInjector(modules: [module]);
660 injector.invoke((@Turbo() Engine e) => id = e.id);
661 expect(id, equals('turbo-engine-id'));
662 });
663
664 }); 587 });
665 } 588 }
666 589
667 void staticInjectorTest() { 590 void staticInjectorTest() {
668 describe('StaticInjector', () { 591 describe('StaticInjector', () {
669 592
670 it('should use type factories passed in the constructor', () { 593 it('should use type factories passed in the constructor', () {
671 var module = new Module() 594 var module = new Module()
672 ..type(Engine); 595 ..type(Engine);
673 var injector = new StaticInjector(modules: [module], typeFactories: { 596 var injector = new StaticInjector(modules: [module], typeFactories: {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 683
761 var engine; 684 var engine;
762 expect(() { 685 expect(() {
763 engine = childInjector.get(Car); 686 engine = childInjector.get(Car);
764 }, isNot(throws)); 687 }, isNot(throws));
765 expect(engine, new isInstanceOf<Car>()); 688 expect(engine, new isInstanceOf<Car>());
766 }); 689 });
767 690
768 }); 691 });
769 } 692 }
770
771 createKeySpec() {
772 describe('Key', () {
773 it('should be equal to another key if type is the same', () {
774 Key k1 = new Key(Car);
775 Key k2 = new Key(Car);
776 expect(k1, equals(k2));
777 expect(k1.hashCode, equals(k2.hashCode));
778 });
779
780 it('should be equal to another key if type and annotation are the same', () {
781 Key k1 = new Key(Car, Turbo);
782 Key k2 = new Key(Car, Turbo);
783 expect(k1, equals(k2));
784 expect(k1.hashCode, equals(k2.hashCode));
785 });
786
787 it('should not be equal to another key if types are different', () {
788 Key k1 = new Key(Car);
789 Key k2 = new Key(Porsche);
790 expect(k1, not(equals(k2)));
791 expect(k1.hashCode, not(equals(k2.hashCode)));
792 });
793
794 it('should not be equal to another key if annotations are different', () {
795 Key k1 = new Key(Car, Turbo);
796 Key k2 = new Key(Car, Old);
797 expect(k1, not(equals(k2)));
798 expect(k1.hashCode, not(equals(k2.hashCode)));
799 });
800
801 it('should not be equal to another key if type is different and annotation'
802 ' is same', () {
803 Key k1 = new Key(Engine, Old);
804 Key k2 = new Key(Car, Old);
805 expect(k1, not(equals(k2)));
806 expect(k1.hashCode, not(equals(k2.hashCode)));
807 });
808 });
809 }
OLDNEW
« no previous file with comments | « third_party/pkg/di/test/injector_generator_spec.dart ('k') | third_party/pkg/di/test/test_annotations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698