| 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 mixin_members_test; |
| 6 |
| 7 // TODO(ahe): Don't add mirrors used, the test doesn't work without it. |
| 8 @MirrorsUsed(targets: 'mixin_members_test', override: '*') |
| 5 import "dart:mirrors"; | 9 import "dart:mirrors"; |
| 6 | 10 |
| 7 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
| 8 | 12 |
| 13 import 'stringify.dart'; |
| 14 |
| 9 class Fooer { | 15 class Fooer { |
| 10 foo1(); | 16 foo1(); |
| 11 } | 17 } |
| 12 | 18 |
| 13 class S implements Fooer { | 19 class S implements Fooer { |
| 14 foo1() {} | 20 foo1() {} |
| 15 foo2() {} | 21 foo2() {} |
| 16 } | 22 } |
| 17 | 23 |
| 18 class M1 { | 24 class M1 { |
| 19 bar1() {} | 25 bar1() {} |
| 20 bar2() {} | 26 bar2() {} |
| 21 } | 27 } |
| 22 | 28 |
| 23 class M2 { | 29 class M2 { |
| 24 baz1() {} | 30 baz1() {} |
| 25 baz2() {} | 31 baz2() {} |
| 26 } | 32 } |
| 27 | 33 |
| 28 class C extends S with M1, M2 {} | 34 class C extends S with M1, M2 {} |
| 29 | 35 |
| 30 main() { | 36 main() { |
| 31 ClassMirror cm = reflectClass(C); | 37 ClassMirror cm = reflectClass(C); |
| 32 Classmirror sM1M2 = cm.superclass; | 38 ClassMirror sM1M2 = cm.superclass; |
| 33 Classmirror sM1 = sM1M2.superclass; | 39 ClassMirror sM1 = sM1M2.superclass; |
| 34 ClassMirror s = sM1.superclass; | 40 ClassMirror s = sM1.superclass; |
| 35 Expect.equals(0, cm.members.length); | 41 expect('{}', cm.members); |
| 36 Expect.setEquals(sM1M2.members.keys, | 42 expect('[s(baz1), s(baz2)]', |
| 37 [const Symbol("baz1"), const Symbol("baz2")]); | 43 // TODO(ahe): Shouldn't have to sort. |
| 38 Expect.setEquals(sM1M2.superinterfaces.map((e) => e.simpleName), | 44 sort(sM1M2.members.keys), |
| 39 [const Symbol("M2")]); | 45 '(S with M1, M2).members'); |
| 40 Expect.setEquals(sM1.members.keys, | 46 expect('[s(M2)]', simpleNames(sM1M2.superinterfaces), |
| 41 [const Symbol("bar1"), const Symbol("bar2")]); | 47 '(S with M1, M2).superinterfaces'); |
| 42 Expect.setEquals(sM1.superinterfaces.map((e) => e.simpleName), | 48 expect('[s(bar1), s(bar2)]', |
| 43 [const Symbol("M1")]); | 49 // TODO(ahe): Shouldn't have to sort. |
| 44 Expect.setEquals(s.members.keys.toSet(), | 50 sort(sM1.members.keys), '(S with M1).members'); |
| 45 [const Symbol("foo1"), const Symbol("foo2")]); | 51 expect('[s(M1)]', simpleNames(sM1.superinterfaces), |
| 46 Expect.setEquals(s.superinterfaces.map((e) => e.simpleName), | 52 '(S with M1).superinterfaces'); |
| 47 [const Symbol("Fooer")]); | 53 expect('[s(foo1), s(foo2)]', |
| 48 Expect.equals(true, reflectClass(S) == s); | 54 // TODO(ahe): Shouldn't have to sort. |
| 55 sort(s.members.keys), 's.members'); |
| 56 expect('[s(Fooer)]', simpleNames(s.superinterfaces), 's.superinterfaces'); |
| 57 Expect.equals(s, reflectClass(S)); |
| 49 } | 58 } |
| OLD | NEW |