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

Side by Side Diff: tests/lib/mirrors/class_mirror_location_test.dart

Issue 922023002: Implement DeclarationMirror.location for all but ParameterMirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.class_location;
6
7 import "dart:mirrors";
8 import "package:expect/expect.dart";
9
10 part 'class_mirror_location_other.dart';
11
12 class ClassInMainFile {}
13 class SpaceIndentedInMainFile {}
14 class TabIndentedInMainFile {}
15
16 abstract class AbstractClass {}
17 typedef bool Predicate(num n);
18
19 class M {}
20 class S {}
21 class MA extends S with M {}
22 class MA2 = S with M;
23
24 const metadata = 'metadata';
25
26 @metadata
27 class WithMetadata {}
28
29 enum Enum { RED, GREEN, BLUE }
30
31 @metadata
32 enum AnnotatedEnum { SALT, PEPPER }
33
34 // We only check for a suffix of the uri because the test might be run from
35 // any number of absolute paths.
36 expectLocation(DeclarationMirror mirror, String uriSuffix, int line, int column) {
37 Uri uri = mirror.location.sourceUri;
38 Expect.isTrue(uri.toString().endsWith(uriSuffix),
39 "Expected suffix $uriSuffix in $uri");
40 Expect.equals(line, mirror.location.line, "line");
41 Expect.equals(column, mirror.location.column, "column");
42 }
43
44 main() {
45 String mainSuffix = 'class_mirror_location_test.dart';
46 String otherSuffix = 'class_mirror_location_other.dart';
47
48 // This file.
49 expectLocation(reflectClass(ClassInMainFile), mainSuffix, 12, 1);
50 expectLocation(reflectClass(SpaceIndentedInMainFile), mainSuffix, 13, 3);
51 expectLocation(reflectClass(TabIndentedInMainFile), mainSuffix, 14, 2);
52 expectLocation(reflectClass(AbstractClass), mainSuffix, 16, 1);
53 expectLocation(reflectType(Predicate), mainSuffix, 17, 1);
54 expectLocation(reflectClass(MA), mainSuffix, 21, 1);
55 expectLocation(reflectClass(MA2), mainSuffix, 22, 1);
56 expectLocation(reflectClass(WithMetadata), mainSuffix, 26, 1);
57 expectLocation(reflectClass(Enum), mainSuffix, 29, 1);
58 expectLocation(reflectClass(AnnotatedEnum), mainSuffix, 31, 1);
59
60 // Another part.
61 expectLocation(reflectClass(ClassInOtherFile), otherSuffix, 7, 1);
62 expectLocation(reflectClass(SpaceIndentedInOtherFile), otherSuffix, 9, 3);
63 expectLocation(reflectClass(TabIndentedInOtherFile), otherSuffix, 11, 2);
64
65 // Synthetic classes.
66 Expect.isNull(reflectClass(MA).superclass.location);
67 Expect.isNull((reflect(main) as ClosureMirror).type.location);
68 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/class_mirror_location_other.dart ('k') | tests/lib/mirrors/library_with_annotated_declaration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698