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

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

Issue 1234053002: Add SubclassNode to prepare for optimized queries on ClassWorld. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. 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 | « tests/compiler/dart2js/class_set_test.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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 world_test; 5 library world_test;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'type_test_helper.dart'; 9 import 'type_test_helper.dart';
10 import 'package:compiler/src/elements/elements.dart' 10 import 'package:compiler/src/elements/elements.dart'
11 show Element, ClassElement; 11 show Element, ClassElement;
12 import 'package:compiler/src/dart2jslib.dart'; 12 import 'package:compiler/src/dart2jslib.dart';
13 13
14 void main() { 14 void main() {
15 asyncTest(() => TypeEnvironment.create(r""" 15 asyncTest(() => TypeEnvironment.create(r"""
16 class A {} 16 class A {}
17 class B {} 17 class B {}
18 class C extends A {} 18 class C_Super extends A {}
19 class C extends C_Super {}
19 class D implements A {} 20 class D implements A {}
20 class E extends B implements A {} 21 class E extends B implements A {}
21 class F extends Object with A implements B {} 22 class F extends Object with A implements B {}
22 class G extends Object with A, B {} 23 class G extends Object with A, B {}
23 """, 24 """,
24 mainSource: r""" 25 mainSource: r"""
25 main() { 26 main() {
26 new A(); 27 new A();
27 new B(); 28 new B();
28 new C(); 29 new C();
(...skipping 27 matching lines...) Expand all
56 "Found:\n ${foundClasses.join('\n ')}"); 57 "Found:\n ${foundClasses.join('\n ')}");
57 } 58 }
58 if (exact) { 59 if (exact) {
59 Expect.equals(expectedClasses.length, foundClasses.length, 60 Expect.equals(expectedClasses.length, foundClasses.length,
60 "Unexpected classes " 61 "Unexpected classes "
61 "${foundClasses.where((c) => !expectedClasses.contains(c))} " 62 "${foundClasses.where((c) => !expectedClasses.contains(c))} "
62 "in '$property' on $cls."); 63 "in '$property' on $cls.");
63 } 64 }
64 } 65 }
65 66
67 void testSubclasses(
68 ClassElement cls,
69 List<ClassElement> expectedClasses,
70 {bool exact: true}) {
71 check(
72 'subclassesOf',
73 cls,
74 classWorld.subclassesOf(cls),
75 expectedClasses,
76 exact: exact);
77 }
78
66 void testStrictSubclasses( 79 void testStrictSubclasses(
67 ClassElement cls, 80 ClassElement cls,
68 List<ClassElement> expectedClasses, 81 List<ClassElement> expectedClasses,
69 {bool exact: true}) { 82 {bool exact: true}) {
70 check( 83 check(
71 'strictSubclassesOf', 84 'strictSubclassesOf',
72 cls, 85 cls,
73 classWorld.strictSubclassesOf(cls), 86 classWorld.strictSubclassesOf(cls),
74 expectedClasses, 87 expectedClasses,
75 exact: exact); 88 exact: exact);
(...skipping 16 matching lines...) Expand all
92 List<ClassElement> expectedClasses, 105 List<ClassElement> expectedClasses,
93 {bool exact: true}) { 106 {bool exact: true}) {
94 check( 107 check(
95 'mixinUsesOf', 108 'mixinUsesOf',
96 cls, 109 cls,
97 classWorld.mixinUsesOf(cls), 110 classWorld.mixinUsesOf(cls),
98 expectedClasses, 111 expectedClasses,
99 exact: exact); 112 exact: exact);
100 } 113 }
101 114
115 testSubclasses(Object_, [A, B, C, D, E, F, G], exact: false);
116 testSubclasses(A, [A, C]);
117 testSubclasses(B, [B, E]);
118 testSubclasses(C, [C]);
119 testSubclasses(D, [D]);
120 testSubclasses(E, [E]);
121 testSubclasses(F, [F]);
122 testSubclasses(G, [G]);
123
102 testStrictSubclasses(Object_, [A, B, C, D, E, F, G], exact: false); 124 testStrictSubclasses(Object_, [A, B, C, D, E, F, G], exact: false);
103 testStrictSubclasses(A, [C]); 125 testStrictSubclasses(A, [C]);
104 testStrictSubclasses(B, [E]); 126 testStrictSubclasses(B, [E]);
105 testStrictSubclasses(C, []); 127 testStrictSubclasses(C, []);
106 testStrictSubclasses(D, []); 128 testStrictSubclasses(D, []);
107 testStrictSubclasses(E, []); 129 testStrictSubclasses(E, []);
108 testStrictSubclasses(F, []); 130 testStrictSubclasses(F, []);
109 testStrictSubclasses(G, []); 131 testStrictSubclasses(G, []);
110 132
111 testStrictSubtypes(Object_, [A, B, C, D, E, F, G], exact: false); 133 testStrictSubtypes(Object_, [A, B, C, D, E, F, G], exact: false);
112 testStrictSubtypes(A, [C, D, E, F, G]); 134 testStrictSubtypes(A, [C, D, E, F, G]);
113 testStrictSubtypes(B, [E, F, G]); 135 testStrictSubtypes(B, [E, F, G]);
114 testStrictSubtypes(C, []); 136 testStrictSubtypes(C, []);
115 testStrictSubtypes(D, []); 137 testStrictSubtypes(D, []);
116 testStrictSubtypes(E, []); 138 testStrictSubtypes(E, []);
117 testStrictSubtypes(F, []); 139 testStrictSubtypes(F, []);
118 testStrictSubtypes(G, []); 140 testStrictSubtypes(G, []);
119 141
120 testMixinUses(Object_, []); 142 testMixinUses(Object_, []);
121 testMixinUses(A, [F.superclass, G.superclass.superclass]); 143 testMixinUses(A, [F.superclass, G.superclass.superclass]);
122 testMixinUses(B, [G.superclass]); 144 testMixinUses(B, [G.superclass]);
123 testMixinUses(C, []); 145 testMixinUses(C, []);
124 testMixinUses(D, []); 146 testMixinUses(D, []);
125 testMixinUses(E, []); 147 testMixinUses(E, []);
126 testMixinUses(F, []); 148 testMixinUses(F, []);
127 testMixinUses(G, []); 149 testMixinUses(G, []);
128 150
129 })); 151 }));
130 } 152 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/class_set_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698