OLD | NEW |
---|---|
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) { | 11 isAnonymousMixinApplication(classMirror) { |
12 return MirrorSystem.getName(classMirror.simpleName).contains(' with '); | 12 return MirrorSystem.getName(classMirror.simpleName).contains(' with '); |
13 } | 13 } |
14 | 14 |
15 checkClass(classMirror) { | 15 checkClass(classMirror) { |
16 Expect.isTrue(classMirror.simpleName is Symbol); | 16 Expect.isTrue(classMirror.simpleName is Symbol); |
17 Expect.notEquals(null, classMirror.owner); | 17 Expect.notEquals(null, classMirror.owner); |
18 Expect.isTrue(classMirror.owner is LibraryMirror); | 18 Expect.isTrue(classMirror.owner is LibraryMirror); |
19 if (!isAnonymousMixinApplication(classMirror)) { | 19 if (!isAnonymousMixinApplication(classMirror)) { |
20 Expect.equals(classMirror.originalDeclaration, | 20 Expect.equals(classMirror.originalDeclaration, |
21 classMirror.owner.declarations[classMirror.simpleName]); | 21 classMirror.owner.declarations[classMirror.simpleName]); |
22 } else { | 22 } else { |
23 Expect.isNull(classMirror.owner.declarations[classMirror.simpleName]); | 23 Expect.isNull(classMirror.owner.declarations[classMirror.simpleName]); |
24 } | 24 } |
25 Expect.isTrue(classMirror.superinterfaces is List); | 25 Expect.isTrue(classMirror.superinterfaces is List); |
26 if (classMirror.superclass == null) { | 26 if (classMirror.superclass == null) { |
27 Expect.equals(reflectClass(Object), classMirror); | 27 Expect.isTrue(classMirror == reflectClass(Object) || |
rmacnak
2017/01/17 17:58:07
I don't see why your change would affect this prop
regis
2017/01/17 18:10:20
Somehow, the mirrors implementation is using VM ty
rmacnak
2017/01/17 18:20:59
I see. LGTM w/ bug filed against this test change.
| |
28 // Type FutureOr is mapped to dynamic in the VM. | |
29 classMirror.toString() == "ClassMirror on 'FutureOr'"); | |
28 } else { | 30 } else { |
29 checkClass(classMirror.superclass); | 31 checkClass(classMirror.superclass); |
30 } | 32 } |
31 } | 33 } |
32 | 34 |
33 checkLibrary(libraryMirror) { | 35 checkLibrary(libraryMirror) { |
34 libraryMirror.declarations.values | 36 libraryMirror.declarations.values |
35 .where((d) => d is ClassMirror) | 37 .where((d) => d is ClassMirror) |
36 .forEach(checkClass); | 38 .forEach(checkClass); |
37 } | 39 } |
38 | 40 |
39 main() { | 41 main() { |
40 currentMirrorSystem().libraries.values.forEach(checkLibrary); | 42 currentMirrorSystem().libraries.values.forEach(checkLibrary); |
41 } | 43 } |
OLD | NEW |