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

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

Issue 257423008: 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';
20 // Generated file. Run ../test_tf_gen.sh. 21 // Generated file. Run ../test_tf_gen.sh.
21 import 'type_factories_gen.dart' as type_factories_gen; 22 import 'type_factories_gen.dart' as type_factories_gen;
22 23
23 /** 24 /**
24 * Annotation used to mark classes for which static type factory must be 25 * Annotation used to mark classes for which static type factory must be
25 * generated. For testing purposes not all classes are marked with this 26 * generated. For testing purposes not all classes are marked with this
26 * annotation, some classes are included in @Injectables at the top. 27 * annotation, some classes are included in @Injectables at the top.
27 */ 28 */
28 class Injectable { 29 class InjectableTest {
29 const Injectable(); 30 const InjectableTest();
30 } 31 }
31 32
32 // just some classes for testing 33 // just some classes for testing
33 @Injectable() 34 @InjectableTest()
34 class Engine { 35 class Engine {
35 final String id = 'v8-id'; 36 final String id = 'v8-id';
36 } 37 }
37 38
38 @Injectable() 39 @Injectable()
39 class MockEngine implements Engine { 40 class MockEngine implements Engine {
40 final String id = 'mock-id'; 41 final String id = 'mock-id';
41 } 42 }
42 43
43 @Injectable() 44 @InjectableTest()
44 class MockEngine2 implements Engine { 45 class MockEngine2 implements Engine {
45 String id = 'mock-id-2'; 46 String id = 'mock-id-2';
46 } 47 }
47 48
48 class HiddenConstructor { 49 class HiddenConstructor {
49 HiddenConstructor._(); 50 HiddenConstructor._();
50 } 51 }
51 52
52 @Injectable() 53 @InjectableTest()
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()
53 class Car { 64 class Car {
54 Engine engine; 65 Engine engine;
55 Injector injector; 66 Injector injector;
56 67
57 Car(this.engine, this.injector); 68 Car(this.engine, this.injector);
58 } 69 }
59 70
60 class Lemon { 71 class Lemon {
61 final engine; 72 final engine;
62 final Injector injector; 73 final Injector injector;
63 74
64 Lemon(this.engine, this.injector); 75 Lemon(this.engine, this.injector);
65 } 76 }
66 77
78 @InjectableTest()
79 class Porsche {
80 Engine engine;
81 Injector injector;
82
83 Porsche(@Turbo() this.engine, this.injector);
84 }
85
67 class NumDependency { 86 class NumDependency {
68 NumDependency(num value) {} 87 NumDependency(num value) {}
69 } 88 }
70 89
71 class IntDependency { 90 class IntDependency {
72 IntDependency(int value) {} 91 IntDependency(int value) {}
73 } 92 }
74 93
75 class DoubleDependency { 94 class DoubleDependency {
76 DoubleDependency(double value) {} 95 DoubleDependency(double value) {}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 130
112 class InterfaceOne { 131 class InterfaceOne {
113 } 132 }
114 133
115 class ClassOne implements InterfaceOne { 134 class ClassOne implements InterfaceOne {
116 ClassOne(Log log) { 135 ClassOne(Log log) {
117 log.add('ClassOne'); 136 log.add('ClassOne');
118 } 137 }
119 } 138 }
120 139
121 @Injectable() 140 @InjectableTest()
122 class ParameterizedType<T1, T2> { 141 class ParameterizedType<T1, T2> {
123 ParameterizedType(); 142 ParameterizedType();
124 } 143 }
125 144
126 @Injectable() 145 @InjectableTest()
127 class ParameterizedDependency { 146 class ParameterizedDependency {
128 final ParameterizedType<bool, int> _p; 147 final ParameterizedType<bool, int> _p;
129 ParameterizedDependency(this._p); 148 ParameterizedDependency(this._p);
130 } 149 }
131 150
132 @Injectable() 151 @InjectableTest()
133 class GenericParameterizedDependency { 152 class GenericParameterizedDependency {
134 final ParameterizedType _p; 153 final ParameterizedType _p;
135 GenericParameterizedDependency(this._p); 154 GenericParameterizedDependency(this._p);
136 } 155 }
137 156
138 @Injectable() 157 @InjectableTest()
139 class Log { 158 class Log {
140 var log = []; 159 var log = [];
141 160
142 add(String message) => log.add(message); 161 add(String message) => log.add(message);
143 } 162 }
144 163
164 @InjectableTest()
165 class AnnotatedPrimitiveDependency {
166 String strValue;
167 AnnotatedPrimitiveDependency(@Turbo() this.strValue);
168 }
169
145 class EmulatedMockEngineFactory { 170 class EmulatedMockEngineFactory {
146 call(Injector i) => new MockEngine(); 171 call(Injector i) => new MockEngine();
147 } 172 }
148 173
174 bool throwOnceShouldThrow = true;
175 @InjectableTest()
176 class ThrowOnce {
177 ThrowOnce() {
178 if (throwOnceShouldThrow) {
179 throwOnceShouldThrow = false;
180 throw ["ThrowOnce"];
181 }
182 }
183 }
184
149 void main() { 185 void main() {
150 createInjectorSpec('DynamicInjector', 186 createInjectorSpec('DynamicInjector',
151 (modules, [name]) => new DynamicInjector(modules: modules, name: name)); 187 (modules, [name]) => new DynamicInjector(modules: modules, name: name));
152 188
153 createInjectorSpec('StaticInjector', 189 createInjectorSpec('StaticInjector',
154 (modules, [name]) => new StaticInjector(modules: modules, name: name, 190 (modules, [name]) => new StaticInjector(modules: modules, name: name,
155 typeFactories: type_factories_gen.typeFactories)); 191 typeFactories: type_factories_gen.typeFactories));
156 192
157 dynamicInjectorTest(); 193 dynamicInjectorTest();
158 staticInjectorTest(); 194 staticInjectorTest();
195 createKeySpec();
159 } 196 }
160 197
161 typedef Injector InjectorFactory(List<Module> modules, [String name]); 198 typedef Injector InjectorFactory(List<Module> modules, [String name]);
162 199
163 createInjectorSpec(String injectorName, InjectorFactory injectorFactory) { 200 createInjectorSpec(String injectorName, InjectorFactory injectorFactory) {
164 201
165 describe(injectorName, () { 202 describe(injectorName, () {
166 203
167 it('should instantiate a type', () { 204 it('should instantiate a type', () {
168 var injector = injectorFactory([new Module()..type(Engine)]); 205 var injector = injectorFactory([new Module()..type(Engine)]);
169 var instance = injector.get(Engine); 206 var instance = injector.get(Engine);
170 207
171 expect(instance, instanceOf(Engine)); 208 expect(instance, instanceOf(Engine));
172 expect(instance.id, toEqual('v8-id')); 209 expect(instance.id, toEqual('v8-id'));
173 }); 210 });
174 211
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
175 it('should fail if no binding is found', () { 223 it('should fail if no binding is found', () {
176 var injector = injectorFactory([]); 224 var injector = injectorFactory([]);
177 expect(() { 225 expect(() {
178 injector.get(Engine); 226 injector.get(Engine);
179 }, toThrow(NoProviderError, 'No provider found for Engine! ' 227 }, toThrow(NoProviderError, 'No provider found for Engine! '
180 '(resolving Engine)')); 228 '(resolving Engine)'));
181 }); 229 });
182 230
183 231
184 it('should resolve basic dependencies', () { 232 it('should resolve basic dependencies', () {
185 var injector = injectorFactory([new Module()..type(Car)..type(Engine)]); 233 var injector = injectorFactory([new Module()..type(Car)..type(Engine)]);
186 var instance = injector.get(Car); 234 var instance = injector.get(Car);
187 235
188 expect(instance, instanceOf(Car)); 236 expect(instance, instanceOf(Car));
189 expect(instance.engine.id, toEqual('v8-id')); 237 expect(instance.engine.id, toEqual('v8-id'));
190 }); 238 });
191 239
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 });
192 262
193 it('should inject generic parameterized types', () { 263 it('should inject generic parameterized types', () {
194 var injector = injectorFactory([new Module() 264 var injector = injectorFactory([new Module()
195 ..type(ParameterizedType) 265 ..type(ParameterizedType)
196 ..type(GenericParameterizedDependency) 266 ..type(GenericParameterizedDependency)
197 ]); 267 ]);
198 expect(injector.get(GenericParameterizedDependency), 268 expect(injector.get(GenericParameterizedDependency),
199 new isInstanceOf<GenericParameterizedDependency>()); 269 new isInstanceOf<GenericParameterizedDependency>());
200 }); 270 });
201 271
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 '(resolving BoolDependency -> bool)')); 384 '(resolving BoolDependency -> bool)'));
315 385
316 expect(() { 386 expect(() {
317 injector.get(StringDependency); 387 injector.get(StringDependency);
318 }, toThrow(NoProviderError, 'Cannot inject a primitive type of String! ' 388 }, toThrow(NoProviderError, 'Cannot inject a primitive type of String! '
319 '(resolving StringDependency -> String)')); 389 '(resolving StringDependency -> String)'));
320 }); 390 });
321 391
322 392
323 it('should throw an exception when circular dependency', () { 393 it('should throw an exception when circular dependency', () {
324 var injector = injectorFactory([new Module()..type(CircularA)..type(Circul arB)]); 394 var injector = injectorFactory([new Module()..type(CircularA)
395 ..type(CircularB)]);
325 396
326 expect(() { 397 expect(() {
327 injector.get(CircularA); 398 injector.get(CircularA);
328 }, toThrow(CircularDependencyError, 'Cannot resolve a circular dependency! ' 399 }, toThrow(CircularDependencyError, 'Cannot resolve a circular '
329 '(resolving CircularA -> ' 400 'dependency! (resolving CircularA -> CircularB -> CircularA'));
330 'CircularB -> CircularA)')); 401 });
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'));
331 }); 412 });
332 413
333 414
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
334 it('should provide the injector as Injector', () { 430 it('should provide the injector as Injector', () {
335 var injector = injectorFactory([]); 431 var injector = injectorFactory([]);
336 432
337 expect(injector.get(Injector), toBe(injector)); 433 expect(injector.get(Injector), toBe(injector));
338 }); 434 });
339 435
340 436
341 it('should inject a typedef', () { 437 it('should inject a typedef', () {
342 var module = new Module()..value(CompareInt, compareIntAsc); 438 var module = new Module()..value(CompareInt, compareIntAsc);
343 439
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 472
377 expect(abcFromParent.id, toEqual('v8-id')); 473 expect(abcFromParent.id, toEqual('v8-id'));
378 expect(abcFromChild.id, toEqual('mock-id')); 474 expect(abcFromChild.id, toEqual('mock-id'));
379 }); 475 });
380 476
381 477
382 it('should enumerate across children', () { 478 it('should enumerate across children', () {
383 var parent = injectorFactory([new Module()..type(Engine)]); 479 var parent = injectorFactory([new Module()..type(Engine)]);
384 var child = parent.createChild([new Module()..type(MockEngine)]); 480 var child = parent.createChild([new Module()..type(MockEngine)]);
385 481
386 expect(parent.types, unorderedEquals(new Set.from([Engine, Injector]))); 482 expect(parent.types, unorderedEquals(new Set.from(
387 expect(child.types, unorderedEquals(new Set.from([Engine, MockEngine, Inje ctor]))); 483 [Engine, Injector])));
484 expect(child.types, unorderedEquals(new Set.from(
485 [Engine, MockEngine, Injector])));
388 }); 486 });
389 487
390 488
391 it('should inject instance from parent if not provided in child', () { 489 it('should inject instance from parent if not provided in child', () {
392 var module = new Module()..type(Car); 490 var module = new Module()..type(Car);
393 491
394 var parent = injectorFactory([new Module()..type(Car)..type(Engine)]); 492 var parent = injectorFactory([new Module()..type(Car)..type(Engine)]);
395 var child = parent.createChild([module]); 493 var child = parent.createChild([module]);
396 494
397 var complexFromParent = parent.get(Car); 495 var complexFromParent = parent.get(Car);
(...skipping 20 matching lines...) Expand all
418 expect(complexFromChild, toBe(complexFromParent)); 516 expect(complexFromChild, toBe(complexFromParent));
419 expect(complexFromChild.engine, toBe(abcFromParent)); 517 expect(complexFromChild.engine, toBe(abcFromParent));
420 expect(complexFromChild.engine, not(toBe(abcFromChild))); 518 expect(complexFromChild.engine, not(toBe(abcFromChild)));
421 }); 519 });
422 520
423 521
424 it('should force new instance in child even if already instantiated in paren t', () { 522 it('should force new instance in child even if already instantiated in paren t', () {
425 var parent = injectorFactory([new Module()..type(Engine)]); 523 var parent = injectorFactory([new Module()..type(Engine)]);
426 var abcAlreadyInParent = parent.get(Engine); 524 var abcAlreadyInParent = parent.get(Engine);
427 525
428 var child = parent.createChild([], forceNewInstances: [Engine]); 526 var child = parent.createChild([], forceNewInstances: [new Key(Engine)]);
429 var abcFromChild = child.get(Engine); 527 var abcFromChild = child.get(Engine);
430 528
431 expect(abcFromChild, not(toBe(abcAlreadyInParent))); 529 expect(abcFromChild, not(toBe(abcAlreadyInParent)));
432 }); 530 });
433 531
434 532
435 it('should force new instance in child using provider from grand parent', () { 533 it('should force new instance in child using provider from grand parent', () {
436 var module = new Module()..type(Engine, implementedBy: MockEngine); 534 var module = new Module()..type(Engine, implementedBy: MockEngine);
437 535
438 var grandParent = injectorFactory([module]); 536 var grandParent = injectorFactory([module]);
439 var parent = grandParent.createChild([]); 537 var parent = grandParent.createChild([]);
440 var child = parent.createChild([], forceNewInstances: [Engine]); 538 var child = parent.createChild([], forceNewInstances: [new Key(Engine)]);
441 539
442 var abcFromGrandParent = grandParent.get(Engine); 540 var abcFromGrandParent = grandParent.get(Engine);
443 var abcFromChild = child.get(Engine); 541 var abcFromChild = child.get(Engine);
444 542
445 expect(abcFromChild.id, toEqual(('mock-id'))); 543 expect(abcFromChild.id, toEqual(('mock-id')));
446 expect(abcFromChild, not(toBe(abcFromGrandParent))); 544 expect(abcFromChild, not(toBe(abcFromGrandParent)));
447 }); 545 });
448 546
449 547
450 it('should provide child injector as Injector', () { 548 it('should provide child injector as Injector', () {
(...skipping 11 matching lines...) Expand all
462 560
463 561
464 it('should set the child injector name', () { 562 it('should set the child injector name', () {
465 var injector = injectorFactory([], 'foo'); 563 var injector = injectorFactory([], 'foo');
466 var childInjector = injector.createChild(null, name: 'bar'); 564 var childInjector = injector.createChild(null, name: 'bar');
467 expect(childInjector.name, 'bar'); 565 expect(childInjector.name, 'bar');
468 }); 566 });
469 567
470 568
471 it('should instantiate class only once (Issue #18)', () { 569 it('should instantiate class only once (Issue #18)', () {
472 var injector = injectorFactory([ 570 var rootInjector = injectorFactory([]);
571 var injector = rootInjector.createChild([
473 new Module() 572 new Module()
474 ..type(Log) 573 ..type(Log)
475 ..type(ClassOne) 574 ..type(ClassOne)
476 ..factory(InterfaceOne, (i) => i.get(ClassOne)) 575 ..factory(InterfaceOne, (i) => i.get(ClassOne))
477 ]); 576 ]);
478 577
479 expect(injector.get(InterfaceOne), same(injector.get(ClassOne))); 578 expect(injector.get(InterfaceOne), same(injector.get(ClassOne)));
480 expect(injector.get(Log).log.join(' '), 'ClassOne'); 579 expect(injector.get(Log).log.join(' '), 'ClassOne');
481 }); 580 });
482 581
483 582
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
524 describe('visiblity', () { 583 describe('visiblity', () {
525 584
526 it('should hide instances', () { 585 it('should hide instances', () {
527 586
528 var rootMock = new MockEngine(); 587 var rootMock = new MockEngine();
529 var childMock = new MockEngine(); 588 var childMock = new MockEngine();
530 589
531 var parentModule = new Module() 590 var parentModule = new Module()
532 ..value(Engine, rootMock); 591 ..value(Engine, rootMock);
533 var childModule = new Module() 592 var childModule = new Module()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 var module = new Module()..type(HiddenConstructor); 636 var module = new Module()..type(HiddenConstructor);
578 var injector = new DynamicInjector(modules: [module]); 637 var injector = new DynamicInjector(modules: [module]);
579 638
580 expect(() { 639 expect(() {
581 injector.get(HiddenConstructor); 640 injector.get(HiddenConstructor);
582 }, toThrow(NoProviderError, startsWith('Unable to find default ' 641 }, toThrow(NoProviderError, startsWith('Unable to find default '
583 'constructor for HiddenConstructor. Make sure class has a ' 642 'constructor for HiddenConstructor. Make sure class has a '
584 'default constructor.'))); 643 'default constructor.')));
585 }); 644 });
586 645
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
587 }); 664 });
588 } 665 }
589 666
590 void staticInjectorTest() { 667 void staticInjectorTest() {
591 describe('StaticInjector', () { 668 describe('StaticInjector', () {
592 669
593 it('should use type factories passed in the constructor', () { 670 it('should use type factories passed in the constructor', () {
594 var module = new Module() 671 var module = new Module()
595 ..type(Engine); 672 ..type(Engine);
596 var injector = new StaticInjector(modules: [module], typeFactories: { 673 var injector = new StaticInjector(modules: [module], typeFactories: {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 760
684 var engine; 761 var engine;
685 expect(() { 762 expect(() {
686 engine = childInjector.get(Car); 763 engine = childInjector.get(Car);
687 }, isNot(throws)); 764 }, isNot(throws));
688 expect(engine, new isInstanceOf<Car>()); 765 expect(engine, new isInstanceOf<Car>());
689 }); 766 });
690 767
691 }); 768 });
692 } 769 }
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