| 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.instance_members; | 5 library test.instance_members; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 import 'declarations_model.dart' as declarations_model; | 10 import 'declarations_model_easier.dart' as declarations_model; |
| 11 | 11 |
| 12 selectKeys(map, predicate) { | 12 selectKeys(map, predicate) { |
| 13 return map.keys.where((key) => predicate(map[key])); | 13 return map.keys.where((key) => predicate(map[key])); |
| 14 } | 14 } |
| 15 | 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 |
| 16 main() { | 33 main() { |
| 17 ClassMirror cm = reflectClass(declarations_model.Class); | 34 ClassMirror cm = reflectClass(declarations_model.Class); |
| 18 | 35 |
| 19 Expect.setEquals( | 36 Expect.setEquals( |
| 20 [#+, | 37 [#+, |
| 21 #instanceVariable, | 38 #instanceVariable, |
| 22 const Symbol('instanceVariable='), | 39 const Symbol('instanceVariable='), |
| 23 #instanceGetter, | 40 #instanceGetter, |
| 24 const Symbol('instanceSetter='), | 41 const Symbol('instanceSetter='), |
| 25 #instanceMethod, | 42 #instanceMethod, |
| 26 #-, | 43 #-, |
| 27 #inheritedInstanceVariable, | 44 #inheritedInstanceVariable, |
| 28 const Symbol('inheritedInstanceVariable='), | 45 const Symbol('inheritedInstanceVariable='), |
| 29 #inheritedInstanceGetter, | 46 #inheritedInstanceGetter, |
| 30 const Symbol('inheritedInstanceSetter='), | 47 const Symbol('inheritedInstanceSetter='), |
| 31 #inheritedInstanceMethod, | 48 #inheritedInstanceMethod, |
| 32 #*, | |
| 33 #mixinInstanceVariable, | |
| 34 const Symbol('mixinInstanceVariable='), | |
| 35 #mixinInstanceGetter, | |
| 36 const Symbol('mixinInstanceSetter='), | |
| 37 #mixinInstanceMethod, | |
| 38 #hashCode, | 49 #hashCode, |
| 39 #runtimeType, | 50 #runtimeType, |
| 40 #==, | 51 #==, |
| 41 #noSuchMethod, | 52 #noSuchMethod, |
| 42 #toString], | 53 #toString], |
| 43 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); | 54 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 44 // Filter out private to avoid implementation-specific members of Object. | 55 // Filter out private to avoid implementation-specific members of Object. |
| 45 | 56 |
| 46 Expect.setEquals( | 57 Expect.setEquals( |
| 47 [#instanceVariable, | 58 [#instanceVariable, |
| 48 const Symbol('instanceVariable='), | 59 const Symbol('instanceVariable='), |
| 49 #inheritedInstanceVariable, | 60 #inheritedInstanceVariable, |
| 50 const Symbol('inheritedInstanceVariable='), | 61 const Symbol('inheritedInstanceVariable=')], |
| 51 #mixinInstanceVariable, | |
| 52 const Symbol('mixinInstanceVariable=')], | |
| 53 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate && dm.isSynthetic)); | 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)); |
| 54 } | 88 } |
| OLD | NEW |