OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.instance_members; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 import 'package:expect/expect.dart'; |
| 9 |
| 10 import 'declarations_model_easier.dart' as declarations_model; |
| 11 |
| 12 selectKeys(map, predicate) { |
| 13 return map.keys.where((key) => predicate(map[key])); |
| 14 } |
| 15 |
| 16 class EasierSuperclass { |
| 17 shuper() {} |
| 18 static staticShuper() {} |
| 19 } |
| 20 class EasierMixin { |
| 21 mixin() {} |
| 22 static staticMixin() {} |
| 23 } |
| 24 class EasierMixinApplication extends EasierSuperclass with EasierMixin { |
| 25 application() {} |
| 26 static staticApplication() {} |
| 27 } |
| 28 class Derived extends EasierMixinApplication { |
| 29 derived() {} |
| 30 static staticDerived() {} |
| 31 } |
| 32 |
| 33 main() { |
| 34 ClassMirror cm = reflectClass(declarations_model.Class); |
| 35 |
| 36 Expect.setEquals( |
| 37 [#+, |
| 38 #instanceVariable, |
| 39 const Symbol('instanceVariable='), |
| 40 #instanceGetter, |
| 41 const Symbol('instanceSetter='), |
| 42 #instanceMethod, |
| 43 #-, |
| 44 #inheritedInstanceVariable, |
| 45 const Symbol('inheritedInstanceVariable='), |
| 46 #inheritedInstanceGetter, |
| 47 const Symbol('inheritedInstanceSetter='), |
| 48 #inheritedInstanceMethod, |
| 49 #hashCode, |
| 50 #runtimeType, |
| 51 #==, |
| 52 #noSuchMethod, |
| 53 #toString], |
| 54 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 55 // Filter out private to avoid implementation-specific members of Object. |
| 56 |
| 57 Expect.setEquals( |
| 58 [#instanceVariable, |
| 59 const Symbol('instanceVariable='), |
| 60 #inheritedInstanceVariable, |
| 61 const Symbol('inheritedInstanceVariable=')], |
| 62 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate && dm.isSynthetic)); |
| 63 |
| 64 cm = reflectClass(Derived); |
| 65 Expect.setEquals( |
| 66 [#derived, |
| 67 #shuper, |
| 68 #mixin, |
| 69 #application, |
| 70 #hashCode, |
| 71 #runtimeType, |
| 72 #==, |
| 73 #noSuchMethod, |
| 74 #toString], |
| 75 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 76 |
| 77 cm = reflectClass(EasierMixinApplication); |
| 78 Expect.setEquals( |
| 79 [#shuper, |
| 80 #mixin, |
| 81 #application, |
| 82 #hashCode, |
| 83 #runtimeType, |
| 84 #==, |
| 85 #noSuchMethod, |
| 86 #toString], |
| 87 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 88 } |
OLD | NEW |