Chromium Code Reviews| Index: tests/lib/mirrors/mixin_members_test.dart |
| diff --git a/tests/lib/mirrors/mixin_members_test.dart b/tests/lib/mirrors/mixin_members_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9d4c05c542482dcc094b4ea5f9890a4bd75733fe |
| --- /dev/null |
| +++ b/tests/lib/mirrors/mixin_members_test.dart |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import "dart:mirrors"; |
| + |
| +import "package:expect/expect.dart"; |
| + |
| +bool haveSameElements(Iterable a, Iterable b) { |
|
ahe
2013/08/06 14:35:36
How about using Expect.listEquals(a.toList(), b.to
rmacnak
2013/08/06 16:33:39
We aren't testing they have the same order.
ahe
2013/08/06 16:42:04
Then Expect.setEquals :-)
Michael Lippautz (Google)
2013/08/06 21:48:29
Done.
|
| + return a.every((e) => b.contains(e)) && |
| + b.every((e) => a.contains(e)); |
| +} |
| + |
| +class Fooer { |
| + foo1(); |
| +} |
| + |
| +class S implements Fooer { |
| + foo1() {} |
| + foo2() {} |
| +} |
| + |
| +class M1 { |
| + bar1() {} |
| + bar2() {} |
| +} |
| + |
| +class M2 { |
| + baz1() {} |
| + baz2() {} |
| +} |
| + |
| +class C extends S with M1, M2 {} |
| + |
| +main() { |
| + ClassMirror cm = reflectClass(C); |
| + Classmirror S_M1_M2 = cm.superclass; |
|
ahe
2013/08/06 14:35:36
Please use camelCase for local variables.
Michael Lippautz (Google)
2013/08/06 21:48:29
Done.
|
| + Classmirror S_M1 = S_M1_M2.superclass; |
| + ClassMirror S = S_M1.superclass; |
|
ahe
2013/08/06 14:35:36
... which avoids hiding types :-)
Michael Lippautz (Google)
2013/08/06 21:48:29
Done.
|
| + Expect.equals(0, cm.members.length); |
| + Expect.isTrue(haveSameElements( |
| + S_M1_M2.members.keys, [const Symbol("baz1"), const Symbol("baz2")])); |
| + Expect.isTrue(haveSameElements( |
| + S_M1_M2.superinterfaces.map((e) => e.simpleName), [const Symbol("M2")])); |
| + Expect.isTrue(haveSameElements( |
| + S_M1.members.keys, [const Symbol("bar1"), const Symbol("bar2")])); |
| + Expect.isTrue(haveSameElements( |
| + S_M1.superinterfaces.map((e) => e.simpleName), [const Symbol("M1")])); |
| + Expect.isTrue(haveSameElements( |
| + S.members.keys.toSet(), [const Symbol("foo1"), const Symbol("foo2")])); |
| + Expect.isTrue(haveSameElements( |
| + S.superinterfaces.map((e) => e.simpleName), [const Symbol("Fooer")])); |
|
ahe
2013/08/06 14:35:36
Could you also test that reflectClass(S) == S
Michael Lippautz (Google)
2013/08/06 21:48:29
Done.
|
| +} |