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

Unified Diff: tests/lib/mirrors/parameter_metadata_test.dart

Issue 23224016: Implement ParameterMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 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
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/parameter_metadata_test.dart
diff --git a/tests/lib/mirrors/parameter_metadata_test.dart b/tests/lib/mirrors/parameter_metadata_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..987e0590d4e8e946bcadb05234cac7e85c547a51
--- /dev/null
+++ b/tests/lib/mirrors/parameter_metadata_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.parameter_metadata_test;
+
+import 'dart:mirrors';
+
+import 'metadata_test.dart';
+
+const m1 = 'm1';
+const m2 = const Symbol('m2');
+const m3 = const CustomAnnotation(3);
+
+class CustomAnnotation {
+ final value;
+ const CustomAnnotation(this.value);
+ toString() => 'CustomAnnotation($value)';
+}
+
+class B {
+ B.foo(int x);
+ factory B.bar(@m3 @m2 int z, x){}
+
+ baz(@m1 final int x, @m2 int y, @m3 final int z);
+ qux(int x, [@m3 @m2 @m1 int y= 3 + 1]);
+ quux(int x, {String str: "foo"});
+ corge({@m1 int x: 3 * 17, @m2 String str: "bar"});
+
+ set x(@m2 final value);
+}
+
+main() {
+ ClassMirror cm = reflectClass(B);
+
+ checkMetadata(cm.constructors[const Symbol('B.foo')].parameters[0], []);
+
+ checkMetadata(cm.constructors[const Symbol('B.bar')].parameters[0], [m3, m2]);
+ checkMetadata(cm.constructors[const Symbol('B.bar')].parameters[1], []);
+
+ checkMetadata(cm.members[const Symbol('baz')].parameters[0], [m1]);
+ checkMetadata(cm.members[const Symbol('baz')].parameters[1], [m2]);
+ checkMetadata(cm.members[const Symbol('baz')].parameters[2], [m3]);
+
+ checkMetadata(cm.members[const Symbol('qux')].parameters[0], []);
+ checkMetadata(cm.members[const Symbol('qux')].parameters[1], [m3, m2, m1]);
+
+ checkMetadata(cm.members[const Symbol('quux')].parameters[0], []);
+ checkMetadata(cm.members[const Symbol('quux')].parameters[1], []);
+
+ checkMetadata(cm.members[const Symbol('corge')].parameters[0], [m1]);
+ checkMetadata(cm.members[const Symbol('corge')].parameters[1], [m2]);
+
+ checkMetadata(cm.members[const Symbol('x=')].parameters[0], [m2]);
+}
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698