OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.declarations_location; |
| 6 |
| 7 import "dart:mirrors"; |
| 8 import "package:expect/expect.dart"; |
| 9 |
| 10 const metadata = 'metadata'; |
| 11 |
| 12 class C<S, @metadata T> { |
| 13 var a; |
| 14 final b = 2; |
| 15 static var c; |
| 16 static final d = 4; |
| 17 @metadata var e; |
| 18 List<C> f; |
| 19 } |
| 20 |
| 21 |
| 22 // We only check for a suffix of the uri because the test might be run from |
| 23 // any number of absolute paths. |
| 24 expectLocation(DeclarationMirror mirror, String uriSuffix, int line, int column)
{ |
| 25 Uri uri = mirror.location.sourceUri; |
| 26 Expect.isTrue(uri.toString().endsWith(uriSuffix), |
| 27 "Expected suffix $uriSuffix in $uri"); |
| 28 Expect.equals(line, mirror.location.line, "line"); |
| 29 Expect.equals(column, mirror.location.column, "column"); |
| 30 } |
| 31 |
| 32 main() { |
| 33 String mainSuffix = 'other_declarations_location_test.dart'; |
| 34 |
| 35 // Fields. |
| 36 expectLocation(reflectClass(C).declarations[#a], mainSuffix, 13, 7); |
| 37 expectLocation(reflectClass(C).declarations[#b], mainSuffix, 14, 9); |
| 38 expectLocation(reflectClass(C).declarations[#c], mainSuffix, 15, 14); |
| 39 expectLocation(reflectClass(C).declarations[#d], mainSuffix, 16, 16); |
| 40 expectLocation(reflectClass(C).declarations[#e], mainSuffix, 17, 17); |
| 41 expectLocation(reflectClass(C).declarations[#f], mainSuffix, 18, 11); |
| 42 |
| 43 // Type variables. |
| 44 expectLocation(reflectClass(C).declarations[#S], mainSuffix, 12, 9); |
| 45 expectLocation(reflectClass(C).declarations[#T], mainSuffix, 12, 12); |
| 46 |
| 47 // Libraries. |
| 48 expectLocation(reflectClass(C).owner, mainSuffix, 1, 1); |
| 49 } |
OLD | NEW |