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

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

Issue 2999373002: Migrated test block 218 to Dart 2.0. (Closed)
Patch Set: Addressed Bob's comments. Created 3 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 unified diff | Download patch
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
14 class SpaceIndentedInMainFile {}
15
16 class TabIndentedInMainFile {}
17
18 abstract class AbstractClass {}
19
20 typedef bool Predicate(num n);
21
22 class M {}
23
24 class S {}
25
26 class MA extends S with M {}
27
28 class MA2 = S with M;
29
30 const metadata = 'metadata';
31
32 @metadata
33 class WithMetadata {}
34
35 enum Enum { RED, GREEN, BLUE }
36
37 @metadata
38 enum AnnotatedEnum { SALT, PEPPER }
39
40 // We only check for a suffix of the uri because the test might be run from
41 // any number of absolute paths.
42 expectLocation(
43 DeclarationMirror mirror, String uriSuffix, int line, int column) {
44 Uri uri = mirror.location.sourceUri;
45 Expect.isTrue(
46 uri.toString().endsWith(uriSuffix), "Expected suffix $uriSuffix in $uri");
47 Expect.equals(line, mirror.location.line, "line");
48 Expect.equals(column, mirror.location.column, "column");
49 }
50
51 main() {
52 String mainSuffix = 'class_mirror_location_test.dart';
53 String otherSuffix = 'class_mirror_location_other.dart';
54
55 // This file.
56 expectLocation(reflectClass(ClassInMainFile), mainSuffix, 12, 1);
57 expectLocation(reflectClass(SpaceIndentedInMainFile), mainSuffix, 13, 3);
58 expectLocation(reflectClass(TabIndentedInMainFile), mainSuffix, 14, 2);
59 expectLocation(reflectClass(AbstractClass), mainSuffix, 16, 1);
60 expectLocation(reflectType(Predicate), mainSuffix, 17, 1);
61 expectLocation(reflectClass(MA), mainSuffix, 21, 1);
62 expectLocation(reflectClass(MA2), mainSuffix, 22, 1);
63 expectLocation(reflectClass(WithMetadata), mainSuffix, 26, 1);
64 expectLocation(reflectClass(Enum), mainSuffix, 29, 1);
65 expectLocation(reflectClass(AnnotatedEnum), mainSuffix, 31, 1);
66
67 // Another part.
68 expectLocation(reflectClass(ClassInOtherFile), otherSuffix, 7, 1);
69 expectLocation(reflectClass(SpaceIndentedInOtherFile), otherSuffix, 9, 3);
70 expectLocation(reflectClass(TabIndentedInOtherFile), otherSuffix, 11, 2);
71
72 // Synthetic classes.
73 Expect.isNull(reflectClass(MA).superclass.location);
74 Expect.isNull((reflect(main) as ClosureMirror).type.location);
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698