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

Side by Side Diff: third_party/pkg/angular/test/core/registry_spec.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
(Empty)
1 library registry_spec;
2
3 import '../_specs.dart';
4
5 main() => describe('RegistryMap', () {
6 it('should throw error on identical keys', () {
7 var module = new Module()
8 ..type(MyMap)
9 ..type(MetadataExtractor)
10 ..type(A1)
11 ..type(A2);
12
13 var injector = new DynamicInjector(modules: [module]);
14 expect(() {
15 injector.get(MyMap);
16 }).toThrow("Duplicate annotation found: MyAnnotation: A. Exisitng:");
17 });
18
19 it('should iterate over all types', () {
20 var module = new Module()
21 ..type(MyMap)
22 ..type(MetadataExtractor)
23 ..type(A1);
24
25 var injector = new DynamicInjector(modules: [module]);
26 var keys = [];
27 var types = [];
28 var map = injector.get(MyMap);
29 map.forEach((k, t) { keys.add(k); types.add(t); });
30 expect(keys).toEqual([new MyAnnotation('A'), new MyAnnotation('B')]);
31 expect(types).toEqual([A1, A1]);
32 });
33 });
34
35 class MyMap extends AnnotationMap<MyAnnotation> {
36 MyMap(Injector injector, MetadataExtractor metadataExtractor)
37 : super(injector, metadataExtractor);
38 }
39
40
41 class MyAnnotation {
42 final String name;
43
44 const MyAnnotation(String this.name);
45
46 toString() => name;
47 get hashCode => name.hashCode;
48 operator==(other) => this.name == other.name;
49 }
50
51 @MyAnnotation('A') @MyAnnotation('B') class A1 {}
52 @MyAnnotation('A') class A2 {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698