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

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

Issue 27226003: Do not hide membership of implementation classes in dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.hierarchy_invariants_test; 5 library test.hierarchy_invariants_test;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 10
11 isAnonymousMixinApplication(classMirror) {
ahe 2013/10/15 07:14:02 Should we have an accessor for this in the API?
12 return MirrorSystem.getName(classMirror.simpleName).contains(' with ');
13 }
14
11 check(classMirror) { 15 check(classMirror) {
12 if (classMirror is TypedefMirror) return; 16 if (classMirror is TypedefMirror) return;
13 17
14 Expect.isTrue(classMirror.simpleName is Symbol); 18 Expect.isTrue(classMirror.simpleName is Symbol);
15 Expect.notEquals(null, classMirror.owner); 19 Expect.notEquals(null, classMirror.owner);
16 Expect.isTrue(classMirror.owner is LibraryMirror); 20 Expect.isTrue(classMirror.owner is LibraryMirror);
21 if (!isAnonymousMixinApplication(classMirror)) {
22 Expect.equals(classMirror.originalDeclaration,
23 classMirror.owner.classes[classMirror.simpleName]);
24 } else {
25 Expect.isNull(classMirror.owner.classes[classMirror.simpleName]);
26 }
17 Expect.isTrue(classMirror.superinterfaces is List); 27 Expect.isTrue(classMirror.superinterfaces is List);
18 if (classMirror.superclass == null) { 28 if (classMirror.superclass == null) {
19 Expect.equals(reflectClass(Object), classMirror); 29 Expect.equals(reflectClass(Object), classMirror);
20 } else { 30 } else {
21 check(classMirror.superclass); 31 check(classMirror.superclass);
22 } 32 }
23 } 33 }
24 34
25 main() { 35 main() {
26 currentMirrorSystem().libraries.values.forEach((libraryMirror) { 36 currentMirrorSystem().libraries.values.forEach((libraryMirror) {
27 libraryMirror.classes.values.forEach((classMirror) { 37 libraryMirror.classes.values.forEach((classMirror) {
28 check(classMirror); 38 check(classMirror);
29 }); 39 });
30 }); 40 });
31 41
32 Expect.throws(() => reflectClass(dynamic), 42 Expect.throws(() => reflectClass(dynamic),
33 (e) => e is ArgumentError, 43 (e) => e is ArgumentError,
34 'dynamic is not a class'); 44 'dynamic is not a class');
35 } 45 }
OLDNEW
« runtime/lib/mirrors.cc ('K') | « tests/lib/mirrors/basic_types_in_dart_core_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698