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

Side by Side Diff: tests/compiler/dart2js/world_test.dart

Issue 1224753002: Remove ClassWorld.subclassesOf and ClassWorld.subtypesOf. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('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) 2014, 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 library world_test;
6
7 import 'package:expect/expect.dart';
8 import 'package:async_helper/async_helper.dart';
9 import 'type_test_helper.dart';
10 import 'package:compiler/src/elements/elements.dart'
11 show Element, ClassElement;
12 import 'package:compiler/src/dart2jslib.dart';
13
14 void main() {
15 asyncTest(() => TypeEnvironment.create(r"""
16 class A {}
17 class B {}
18 class C extends A {}
19 class D implements A {}
20 class E extends B implements A {}
21 class F extends Object with A implements B {}
22 class G extends Object with A, B {}
23 """,
24 mainSource: r"""
25 main() {
26 new A();
27 new B();
28 new C();
29 new D();
30 new E();
31 new F();
32 new G();
33 }
34 """,
35 useMockCompiler: false).then((env) {
36 ClassWorld classWorld = env.compiler.world;
37
38 ClassElement Object_ = env.getElement("Object");
39 ClassElement A = env.getElement("A");
40 ClassElement B = env.getElement("B");
41 ClassElement C = env.getElement("C");
42 ClassElement D = env.getElement("D");
43 ClassElement E = env.getElement("E");
44 ClassElement F = env.getElement("F");
45 ClassElement G = env.getElement("G");
46
47 void check(
48 String property,
49 ClassElement cls,
50 Iterable<ClassElement> foundClasses,
51 List<ClassElement> expectedClasses,
52 {bool exact: true}) {
53 for (ClassElement expectedClass in expectedClasses) {
54 Expect.isTrue(foundClasses.contains(expectedClass),
55 "Expect $expectedClass in '$property' on $cls. "
56 "Found:\n ${foundClasses.join('\n ')}");
57 }
58 if (exact) {
59 Expect.equals(expectedClasses.length, foundClasses.length,
60 "Unexpected classes "
61 "${foundClasses.where((c) => !expectedClasses.contains(c))} "
62 "in '$property' on $cls.");
63 }
64 }
65
66 void testStrictSubclasses(
67 ClassElement cls,
68 List<ClassElement> expectedClasses,
69 {bool exact: true}) {
70 check(
71 'strictSubclassesOf',
72 cls,
73 classWorld.strictSubclassesOf(cls),
74 expectedClasses,
75 exact: exact);
76 }
77
78 void testStrictSubtypes(
79 ClassElement cls,
80 List<ClassElement> expectedClasses,
81 {bool exact: true}) {
82 check(
83 'strictSubtypesOf',
84 cls,
85 classWorld.strictSubtypesOf(cls),
86 expectedClasses,
87 exact: exact);
88 }
89
90 void testMixinUses(
91 ClassElement cls,
92 List<ClassElement> expectedClasses,
93 {bool exact: true}) {
94 check(
95 'mixinUsesOf',
96 cls,
97 classWorld.mixinUsesOf(cls),
98 expectedClasses,
99 exact: exact);
100 }
101
102 testStrictSubclasses(Object_, [A, B, C, D, E, F, G], exact: false);
103 testStrictSubclasses(A, [C]);
104 testStrictSubclasses(B, [E]);
105 testStrictSubclasses(C, []);
106 testStrictSubclasses(D, []);
107 testStrictSubclasses(E, []);
108 testStrictSubclasses(F, []);
109 testStrictSubclasses(G, []);
110
111 testStrictSubtypes(Object_, [A, B, C, D, E, F, G], exact: false);
112 testStrictSubtypes(A, [C, D, E, F, G]);
113 testStrictSubtypes(B, [E, F, G]);
114 testStrictSubtypes(C, []);
115 testStrictSubtypes(D, []);
116 testStrictSubtypes(E, []);
117 testStrictSubtypes(F, []);
118 testStrictSubtypes(G, []);
119
120 testMixinUses(Object_, []);
121 testMixinUses(A, [F.superclass, G.superclass.superclass]);
122 testMixinUses(B, [G.superclass]);
123 testMixinUses(C, []);
124 testMixinUses(D, []);
125 testMixinUses(E, []);
126 testMixinUses(F, []);
127 testMixinUses(G, []);
128
129 }));
130 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698