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

Unified 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, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/core/registry_spec.dart
diff --git a/third_party/pkg/angular/test/core/registry_spec.dart b/third_party/pkg/angular/test/core/registry_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..940c9ba9072c51cd85268c5c559a24212feb6c71
--- /dev/null
+++ b/third_party/pkg/angular/test/core/registry_spec.dart
@@ -0,0 +1,52 @@
+library registry_spec;
+
+import '../_specs.dart';
+
+main() => describe('RegistryMap', () {
+ it('should throw error on identical keys', () {
+ var module = new Module()
+ ..type(MyMap)
+ ..type(MetadataExtractor)
+ ..type(A1)
+ ..type(A2);
+
+ var injector = new DynamicInjector(modules: [module]);
+ expect(() {
+ injector.get(MyMap);
+ }).toThrow("Duplicate annotation found: MyAnnotation: A. Exisitng:");
+ });
+
+ it('should iterate over all types', () {
+ var module = new Module()
+ ..type(MyMap)
+ ..type(MetadataExtractor)
+ ..type(A1);
+
+ var injector = new DynamicInjector(modules: [module]);
+ var keys = [];
+ var types = [];
+ var map = injector.get(MyMap);
+ map.forEach((k, t) { keys.add(k); types.add(t); });
+ expect(keys).toEqual([new MyAnnotation('A'), new MyAnnotation('B')]);
+ expect(types).toEqual([A1, A1]);
+ });
+});
+
+class MyMap extends AnnotationMap<MyAnnotation> {
+ MyMap(Injector injector, MetadataExtractor metadataExtractor)
+ : super(injector, metadataExtractor);
+}
+
+
+class MyAnnotation {
+ final String name;
+
+ const MyAnnotation(String this.name);
+
+ toString() => name;
+ get hashCode => name.hashCode;
+ operator==(other) => this.name == other.name;
+}
+
+@MyAnnotation('A') @MyAnnotation('B') class A1 {}
+@MyAnnotation('A') class A2 {}

Powered by Google App Engine
This is Rietveld 408576698