| 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 }); |
| 33 }); | 43 }); |
| 34 | 44 |
| 45 typedef void MyTypedef(String arg); |
| 46 |
| 35 class MyMap extends AnnotationMap<MyAnnotation> { | 47 class MyMap extends AnnotationMap<MyAnnotation> { |
| 36 MyMap(Injector injector, MetadataExtractor metadataExtractor) | 48 MyMap(Injector injector, MetadataExtractor metadataExtractor) |
| 37 : super(injector, metadataExtractor); | 49 : super(injector, metadataExtractor); |
| 38 } | 50 } |
| 39 | 51 |
| 40 | 52 |
| 41 class MyAnnotation { | 53 class MyAnnotation { |
| 42 final String name; | 54 final String name; |
| 43 | 55 |
| 44 const MyAnnotation(String this.name); | 56 const MyAnnotation(String this.name); |
| 45 | 57 |
| 46 toString() => name; | 58 toString() => name; |
| 47 get hashCode => name.hashCode; | 59 get hashCode => name.hashCode; |
| 48 operator==(other) => this.name == other.name; | 60 operator==(other) => this.name == other.name; |
| 49 } | 61 } |
| 50 | 62 |
| 51 @MyAnnotation('A') @MyAnnotation('B') class A1 {} | 63 @MyAnnotation('A') @MyAnnotation('B') class A1 {} |
| 52 @MyAnnotation('A') class A2 {} | 64 @MyAnnotation('A') class A2 {} |
| OLD | NEW |