Index: tests/lib/mirrors/other_declarations_location_test.dart |
diff --git a/tests/lib/mirrors/other_declarations_location_test.dart b/tests/lib/mirrors/other_declarations_location_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..003bcc33353a18fba5c3612bdf262a43a8bf146b |
--- /dev/null |
+++ b/tests/lib/mirrors/other_declarations_location_test.dart |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2015, 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.declarations_location; |
+ |
+import "dart:mirrors"; |
+import "package:expect/expect.dart"; |
+ |
+const metadata = 'metadata'; |
+ |
+class C<S, @metadata T> { |
+ var a; |
+ final b = 2; |
+ static var c; |
+ static final d = 4; |
+ @metadata var e; |
+ List<C> f; |
+} |
+ |
+ |
+// We only check for a suffix of the uri because the test might be run from |
+// any number of absolute paths. |
+expectLocation(DeclarationMirror mirror, String uriSuffix, int line, int column) { |
+ Uri uri = mirror.location.sourceUri; |
+ Expect.isTrue(uri.toString().endsWith(uriSuffix), |
+ "Expected suffix $uriSuffix in $uri"); |
+ Expect.equals(line, mirror.location.line, "line"); |
+ Expect.equals(column, mirror.location.column, "column"); |
+} |
+ |
+main() { |
+ String mainSuffix = 'other_declarations_location_test.dart'; |
+ |
+ // Fields. |
+ expectLocation(reflectClass(C).declarations[#a], mainSuffix, 13, 7); |
+ expectLocation(reflectClass(C).declarations[#b], mainSuffix, 14, 9); |
+ expectLocation(reflectClass(C).declarations[#c], mainSuffix, 15, 14); |
+ expectLocation(reflectClass(C).declarations[#d], mainSuffix, 16, 16); |
+ expectLocation(reflectClass(C).declarations[#e], mainSuffix, 17, 17); |
+ expectLocation(reflectClass(C).declarations[#f], mainSuffix, 18, 11); |
+ |
+ // Type variables. |
+ expectLocation(reflectClass(C).declarations[#S], mainSuffix, 12, 9); |
+ expectLocation(reflectClass(C).declarations[#T], mainSuffix, 12, 12); |
+ |
+ // Libraries. |
+ expectLocation(reflectClass(C).owner, mainSuffix, 1, 1); |
+} |