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

Unified Diff: test_reflectable/test/meta_reflectors_test.dart

Issue 1391543003: Creates `reflectors`, as a meta-meta feature that enables dynamic selection of a "mirror system". (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Added lots of LibraryMirror support in order to make reflectors work in transformed code Created 5 years, 2 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: test_reflectable/test/meta_reflectors_test.dart
diff --git a/test_reflectable/test/meta_reflectors_test.dart b/test_reflectable/test/meta_reflectors_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3ebf33472c8efff8a0a0c720776c6e451191be45
--- /dev/null
+++ b/test_reflectable/test/meta_reflectors_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2015, the Dart Team. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+// File being transformed by the reflectable transformer.
+// Creates a `MetaReflector` which may be used to reflect on the set of
+// reflectors themselves.
+//
+// Independence: This is the only library in this program where both the
+// reflector classes and the domain classes are seen together. The program
+// as a whole illustrates a number of ways in which it is possible to make
+// reflection, usage of reflection, and application specific classes (here
+// known as 'domain classes') independent of each other, statically and
+// dynamically.
+
+library test_reflectable.test.meta_reflectors_test;
+
+@GlobalQuantifyCapability(r"\.(M1|M2|M3|A|B|C|D)$", const Reflector())
+@GlobalQuantifyCapability(r"\.(M1|M2|M3|B|C|D)$", const Reflector2())
+@GlobalQuantifyCapability(r"\.(C|D)$", const ReflectorUpwardsClosed())
+@GlobalQuantifyCapability(r"\.(C|D)$", const ReflectorUpwardsClosedToA())
+@GlobalQuantifyCapability(r"\.(C|D)$", const ReflectorUpwardsClosedUntilA())
+import "package:reflectable/reflectable.dart";
+import "meta_reflectors_domain_definer.dart";
+import "meta_reflectors_definer.dart";
+import "meta_reflectors_scoping.dart";
+import "meta_reflectors_user.dart";
+
+Map<String, Iterable<Reflectable>> scopeMap = <String, Iterable<Reflectable>>{
sigurdm 2015/10/09 07:52:04 While this is a perfectly valid approach, I still
eernst 2015/10/09 10:09:05 Why don't you write that as an extra test case? ;)
sigurdm 2015/10/09 10:47:20 Good idea!
+ "polymer": <Reflectable>[const Reflector(), const ReflectorUpwardsClosed()],
+ "observe": <Reflectable>[const Reflector2(), const ReflectorUpwardsClosed()]
+};
+
+@ScopeMetaReflector()
+Iterable<Reflectable> reflectablesOfScope(String scope) => scopeMap[scope];
+
+main() {
+ doit();
+}

Powered by Google App Engine
This is Rietveld 408576698