| OLD | NEW |
| 1 library registry_spec; | 1 library registry_spec; |
| 2 | 2 |
| 3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
| 4 | 4 |
| 5 main() => describe('RegistryMap', () { | 5 main() => describe('RegistryMap', () { |
| 6 it('should allow for multiple registry keys to be added', () { | 6 it('should allow for multiple registry keys to be added', () { |
| 7 var module = new Module() | 7 var module = new Module() |
| 8 ..type(MyMap) | 8 ..type(MyMap) |
| 9 ..type(MetadataExtractor) | 9 ..type(MetadataExtractor) |
| 10 ..type(A1) | 10 ..type(A1) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ..type(A1); | 23 ..type(A1); |
| 24 | 24 |
| 25 var injector = new DynamicInjector(modules: [module]); | 25 var injector = new DynamicInjector(modules: [module]); |
| 26 var keys = []; | 26 var keys = []; |
| 27 var types = []; | 27 var types = []; |
| 28 var map = injector.get(MyMap); | 28 var map = injector.get(MyMap); |
| 29 map.forEach((k, t) { keys.add(k); types.add(t); }); | 29 map.forEach((k, t) { keys.add(k); types.add(t); }); |
| 30 expect(keys).toEqual([new MyAnnotation('A'), new MyAnnotation('B')]); | 30 expect(keys).toEqual([new MyAnnotation('A'), new MyAnnotation('B')]); |
| 31 expect(types).toEqual([A1, A1]); | 31 expect(types).toEqual([A1, A1]); |
| 32 }); | 32 }); |
| 33 | |
| 34 it('should safely ignore typedefs', () { | |
| 35 var module = new Module() | |
| 36 ..type(MyMap) | |
| 37 ..type(MetadataExtractor) | |
| 38 ..value(MyTypedef, (String _) => null); | |
| 39 | |
| 40 var injector = new DynamicInjector(modules: [module]); | |
| 41 expect(() => injector.get(MyMap), isNot(throws)); | |
| 42 }); | |
| 43 }); | 33 }); |
| 44 | 34 |
| 45 typedef void MyTypedef(String arg); | |
| 46 | |
| 47 class MyMap extends AnnotationMap<MyAnnotation> { | 35 class MyMap extends AnnotationMap<MyAnnotation> { |
| 48 MyMap(Injector injector, MetadataExtractor metadataExtractor) | 36 MyMap(Injector injector, MetadataExtractor metadataExtractor) |
| 49 : super(injector, metadataExtractor); | 37 : super(injector, metadataExtractor); |
| 50 } | 38 } |
| 51 | 39 |
| 52 | 40 |
| 53 class MyAnnotation { | 41 class MyAnnotation { |
| 54 final String name; | 42 final String name; |
| 55 | 43 |
| 56 const MyAnnotation(String this.name); | 44 const MyAnnotation(String this.name); |
| 57 | 45 |
| 58 toString() => name; | 46 toString() => name; |
| 59 get hashCode => name.hashCode; | 47 get hashCode => name.hashCode; |
| 60 operator==(other) => this.name == other.name; | 48 operator==(other) => this.name == other.name; |
| 61 } | 49 } |
| 62 | 50 |
| 63 @MyAnnotation('A') @MyAnnotation('B') class A1 {} | 51 @MyAnnotation('A') @MyAnnotation('B') class A1 {} |
| 64 @MyAnnotation('A') class A2 {} | 52 @MyAnnotation('A') class A2 {} |
| OLD | NEW |