Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: tests/lib/mirrors/mixin_members_test.dart

Issue 21155003: Improve test coverage for reflection on mixins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 import "dart:mirrors";
6
7 import "package:expect/expect.dart";
8
9 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.
10 return a.every((e) => b.contains(e)) &&
11 b.every((e) => a.contains(e));
12 }
13
14 class Fooer {
15 foo1();
16 }
17
18 class S implements Fooer {
19 foo1() {}
20 foo2() {}
21 }
22
23 class M1 {
24 bar1() {}
25 bar2() {}
26 }
27
28 class M2 {
29 baz1() {}
30 baz2() {}
31 }
32
33 class C extends S with M1, M2 {}
34
35 main() {
36 ClassMirror cm = reflectClass(C);
37 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.
38 Classmirror S_M1 = S_M1_M2.superclass;
39 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.
40 Expect.equals(0, cm.members.length);
41 Expect.isTrue(haveSameElements(
42 S_M1_M2.members.keys, [const Symbol("baz1"), const Symbol("baz2")]));
43 Expect.isTrue(haveSameElements(
44 S_M1_M2.superinterfaces.map((e) => e.simpleName), [const Symbol("M2")]));
45 Expect.isTrue(haveSameElements(
46 S_M1.members.keys, [const Symbol("bar1"), const Symbol("bar2")]));
47 Expect.isTrue(haveSameElements(
48 S_M1.superinterfaces.map((e) => e.simpleName), [const Symbol("M1")]));
49 Expect.isTrue(haveSameElements(
50 S.members.keys.toSet(), [const Symbol("foo1"), const Symbol("foo2")]));
51 Expect.isTrue(haveSameElements(
52 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.
53 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698