| 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_easier.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 { | 16 class EasierSuperclass { |
| 17 shuper() {} | 17 shuper() {} |
| 18 static staticShuper() {} | 18 static staticShuper() {} |
| 19 } | 19 } |
| 20 |
| 20 class EasierMixin { | 21 class EasierMixin { |
| 21 mixin() {} | 22 mixin() {} |
| 22 static staticMixin() {} | 23 static staticMixin() {} |
| 23 } | 24 } |
| 25 |
| 24 class EasierMixinApplication extends EasierSuperclass with EasierMixin { | 26 class EasierMixinApplication extends EasierSuperclass with EasierMixin { |
| 25 application() {} | 27 application() {} |
| 26 static staticApplication() {} | 28 static staticApplication() {} |
| 27 } | 29 } |
| 30 |
| 28 class Derived extends EasierMixinApplication { | 31 class Derived extends EasierMixinApplication { |
| 29 derived() {} | 32 derived() {} |
| 30 static staticDerived() {} | 33 static staticDerived() {} |
| 31 } | 34 } |
| 32 | 35 |
| 33 main() { | 36 main() { |
| 34 ClassMirror cm = reflectClass(declarations_model.Class); | 37 ClassMirror cm = reflectClass(declarations_model.Class); |
| 35 | 38 |
| 36 Expect.setEquals( | 39 Expect.setEquals([ |
| 37 [#+, | 40 #+, |
| 38 #instanceVariable, | 41 #instanceVariable, |
| 39 const Symbol('instanceVariable='), | 42 const Symbol('instanceVariable='), |
| 40 #instanceGetter, | 43 #instanceGetter, |
| 41 const Symbol('instanceSetter='), | 44 const Symbol('instanceSetter='), |
| 42 #instanceMethod, | 45 #instanceMethod, |
| 43 #-, | 46 #-, |
| 44 #inheritedInstanceVariable, | 47 #inheritedInstanceVariable, |
| 45 const Symbol('inheritedInstanceVariable='), | 48 const Symbol('inheritedInstanceVariable='), |
| 46 #inheritedInstanceGetter, | 49 #inheritedInstanceGetter, |
| 47 const Symbol('inheritedInstanceSetter='), | 50 const Symbol('inheritedInstanceSetter='), |
| 48 #inheritedInstanceMethod, | 51 #inheritedInstanceMethod, |
| 49 #hashCode, | 52 #hashCode, |
| 50 #runtimeType, | 53 #runtimeType, |
| 51 #==, | 54 #==, |
| 52 #noSuchMethod, | 55 #noSuchMethod, |
| 53 #toString], | 56 #toString |
| 54 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); | 57 ], selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 55 // Filter out private to avoid implementation-specific members of Object. | 58 // Filter out private to avoid implementation-specific members of Object. |
| 56 | 59 |
| 57 Expect.setEquals( | 60 Expect.setEquals([ |
| 58 [#instanceVariable, | 61 #instanceVariable, |
| 59 const Symbol('instanceVariable='), | 62 const Symbol('instanceVariable='), |
| 60 #inheritedInstanceVariable, | 63 #inheritedInstanceVariable, |
| 61 const Symbol('inheritedInstanceVariable=')], | 64 const Symbol('inheritedInstanceVariable=') |
| 62 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate && dm.isSynthetic)); | 65 ], selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate && dm.isSynthetic)); |
| 63 | 66 |
| 64 cm = reflectClass(Derived); | 67 cm = reflectClass(Derived); |
| 65 Expect.setEquals( | 68 Expect.setEquals([ |
| 66 [#derived, | 69 #derived, |
| 67 #shuper, | 70 #shuper, |
| 68 #mixin, | 71 #mixin, |
| 69 #application, | 72 #application, |
| 70 #hashCode, | 73 #hashCode, |
| 71 #runtimeType, | 74 #runtimeType, |
| 72 #==, | 75 #==, |
| 73 #noSuchMethod, | 76 #noSuchMethod, |
| 74 #toString], | 77 #toString |
| 75 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); | 78 ], selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 76 | 79 |
| 77 cm = reflectClass(EasierMixinApplication); | 80 cm = reflectClass(EasierMixinApplication); |
| 78 Expect.setEquals( | 81 Expect.setEquals([ |
| 79 [#shuper, | 82 #shuper, |
| 80 #mixin, | 83 #mixin, |
| 81 #application, | 84 #application, |
| 82 #hashCode, | 85 #hashCode, |
| 83 #runtimeType, | 86 #runtimeType, |
| 84 #==, | 87 #==, |
| 85 #noSuchMethod, | 88 #noSuchMethod, |
| 86 #toString], | 89 #toString |
| 87 selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); | 90 ], selectKeys(cm.instanceMembers, (dm) => !dm.isPrivate)); |
| 88 } | 91 } |
| OLD | NEW |