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

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

Issue 1677423002: Revert "Fix super noSuchMethod handling." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2015, 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 import 'dart:async';
6 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
7 import 'package:async_helper/async_helper.dart'; 6 import "package:async_helper/async_helper.dart";
8 import 'compiler_helper.dart'; 7 import 'compiler_helper.dart';
9 8
10 Future dummyImplTest() async { 9 dummyImplTest() {
11 String source = """ 10 String source = """
12 class A { 11 class A {
13 foo() => 3; 12 foo() => 3;
14 noSuchMethod(x) => super.noSuchMethod(x); 13 noSuchMethod(x) => super.noSuchMethod(x);
15 } 14 }
16 main() { 15 main() {
17 print(new A().foo()); 16 print(new A().foo());
18 } 17 }
19 """; 18 """;
20 Uri uri = new Uri(scheme: 'source'); 19 Uri uri = new Uri(scheme: 'source');
21 var compiler = compilerFor(source, uri); 20 var compiler = compilerFor(source, uri);
22 await compiler.run(uri); 21 asyncTest(() => compiler.run(uri).then((_) {
23 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 22 Expect.isFalse(compiler.backend.enabledNoSuchMethod);
24 ClassElement clsA = findElement(compiler, 'A'); 23 ClassElement clsA = findElement(compiler, 'A');
25 Expect.isTrue( 24 Expect.isTrue(
26 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 25 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
27 clsA.lookupMember('noSuchMethod'))); 26 clsA.lookupMember('noSuchMethod')));
27 }));
28 } 28 }
29 29
30 Future dummyImplTest2() async { 30 dummyImplTest2() {
31 String source = """ 31 String source = """
32 class A extends B { 32 class A extends B {
33 foo() => 3; 33 foo() => 3;
34 noSuchMethod(x) => super.noSuchMethod(x); 34 noSuchMethod(x) => super.noSuchMethod(x);
35 } 35 }
36 class B {} 36 class B {}
37 main() { 37 main() {
38 print(new A().foo()); 38 print(new A().foo());
39 } 39 }
40 """; 40 """;
41 Uri uri = new Uri(scheme: 'source'); 41 Uri uri = new Uri(scheme: 'source');
42 var compiler = compilerFor(source, uri); 42 var compiler = compilerFor(source, uri);
43 await compiler.run(uri); 43 asyncTest(() => compiler.run(uri).then((_) {
44 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 44 Expect.isFalse(compiler.backend.enabledNoSuchMethod);
45 ClassElement clsA = findElement(compiler, 'A'); 45 ClassElement clsA = findElement(compiler, 'A');
46 Expect.isTrue( 46 Expect.isTrue(
47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
48 clsA.lookupMember('noSuchMethod'))); 48 clsA.lookupMember('noSuchMethod')));
49 }));
49 } 50 }
50 51
51 Future dummyImplTest3() async { 52 dummyImplTest3() {
52 String source = """ 53 String source = """
53 class A extends B { 54 class A extends B {
54 foo() => 3; 55 foo() => 3;
55 noSuchMethod(x) { 56 noSuchMethod(x) {
56 return super.noSuchMethod(x); 57 return super.noSuchMethod(x);
57 } 58 }
58 } 59 }
59 class B {} 60 class B {}
60 main() { 61 main() {
61 print(new A().foo()); 62 print(new A().foo());
62 } 63 }
63 """; 64 """;
64 Uri uri = new Uri(scheme: 'source'); 65 Uri uri = new Uri(scheme: 'source');
65 var compiler = compilerFor(source, uri); 66 var compiler = compilerFor(source, uri);
66 await compiler.run(uri); 67 asyncTest(() => compiler.run(uri).then((_) {
67 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 68 Expect.isFalse(compiler.backend.enabledNoSuchMethod);
68 ClassElement clsA = findElement(compiler, 'A'); 69 ClassElement clsA = findElement(compiler, 'A');
69 Expect.isTrue( 70 Expect.isTrue(
70 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 71 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
71 clsA.lookupMember('noSuchMethod'))); 72 clsA.lookupMember('noSuchMethod')));
73 }));
72 } 74 }
73 75
74 Future dummyImplTest4() async { 76 dummyImplTest4() {
75 String source = """ 77 String source = """
76 class A extends B { 78 class A extends B {
77 foo() => 3; 79 foo() => 3;
78 noSuchMethod(x) => super.noSuchMethod(x); 80 noSuchMethod(x) => super.noSuchMethod(x);
79 } 81 }
80 class B { 82 class B {
81 noSuchMethod(x) => super.noSuchMethod(x); 83 noSuchMethod(x) => super.noSuchMethod(x);
82 } 84 }
83 main() { 85 main() {
84 print(new A().foo()); 86 print(new A().foo());
85 } 87 }
86 """; 88 """;
87 Uri uri = new Uri(scheme: 'source'); 89 Uri uri = new Uri(scheme: 'source');
88 var compiler = compilerFor(source, uri); 90 var compiler = compilerFor(source, uri);
89 await compiler.run(uri); 91 asyncTest(() => compiler.run(uri).then((_) {
90 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 92 Expect.isFalse(compiler.backend.enabledNoSuchMethod);
91 ClassElement clsA = findElement(compiler, 'A'); 93 ClassElement clsA = findElement(compiler, 'A');
92 Expect.isTrue( 94 Expect.isTrue(
93 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 95 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
94 clsA.lookupMember('noSuchMethod'))); 96 clsA.lookupMember('noSuchMethod')));
95 ClassElement clsB = findElement(compiler, 'B'); 97 ClassElement clsB = findElement(compiler, 'B');
96 Expect.isTrue( 98 Expect.isTrue(
97 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 99 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
98 clsB.lookupMember('noSuchMethod'))); 100 clsB.lookupMember('noSuchMethod')));
101 }));
99 } 102 }
100 103
101 Future dummyImplTest5() async { 104 dummyImplTest5() {
102 String source = """ 105 String source = """
103 class A extends B { 106 class A extends B {
104 foo() => 3; 107 foo() => 3;
105 noSuchMethod(x) => super.noSuchMethod(x); 108 noSuchMethod(x) => super.noSuchMethod(x);
106 } 109 }
107 class B { 110 class B {
108 noSuchMethod(x) => throw 'foo'; 111 noSuchMethod(x) => throw 'foo';
109 } 112 }
110 main() { 113 main() {
111 print(new A().foo()); 114 print(new A().foo());
112 } 115 }
113 """; 116 """;
114 Uri uri = new Uri(scheme: 'source'); 117 Uri uri = new Uri(scheme: 'source');
115 var compiler = compilerFor(source, uri); 118 var compiler = compilerFor(source, uri);
116 await compiler.run(uri); 119 asyncTest(() => compiler.run(uri).then((_) {
117 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 120 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
118 ClassElement clsA = findElement(compiler, 'A'); 121 ClassElement clsA = findElement(compiler, 'A');
119 Expect.isTrue( 122 Expect.isTrue(
120 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( 123 compiler.backend.noSuchMethodRegistry.throwingImpls.contains(
121 clsA.lookupMember('noSuchMethod'))); 124 clsA.lookupMember('noSuchMethod')));
122 ClassElement clsB = findElement(compiler, 'B'); 125 ClassElement clsB = findElement(compiler, 'B');
123 Expect.isTrue( 126 Expect.isTrue(
124 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( 127 compiler.backend.noSuchMethodRegistry.throwingImpls.contains(
125 clsB.lookupMember('noSuchMethod'))); 128 clsB.lookupMember('noSuchMethod')));
129 }));
126 } 130 }
127 131
128 Future dummyImplTest6() async { 132 dummyImplTest6() {
129 String source = """ 133 String source = """
130 class A { 134 class A {
131 noSuchMethod(x) => 3; 135 noSuchMethod(x) => 3;
132 } 136 }
133 main() { 137 main() {
134 print(new A().foo()); 138 print(new A().foo());
135 } 139 }
136 """; 140 """;
137 Uri uri = new Uri(scheme: 'source'); 141 Uri uri = new Uri(scheme: 'source');
138 var compiler = compilerFor(source, uri); 142 var compiler = compilerFor(source, uri);
139 await compiler.run(uri); 143 asyncTest(() => compiler.run(uri).then((_) {
140 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 144 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
141 ClassElement clsA = findElement(compiler, 'A'); 145 ClassElement clsA = findElement(compiler, 'A');
142 Expect.isTrue( 146 Expect.isTrue(
143 compiler.backend.noSuchMethodRegistry.otherImpls.contains( 147 compiler.backend.noSuchMethodRegistry.otherImpls.contains(
144 clsA.lookupMember('noSuchMethod'))); 148 clsA.lookupMember('noSuchMethod')));
149 }));
145 } 150 }
146 151
147 Future dummyImplTest7() async { 152 dummyImplTest7() {
148 String source = """ 153 String source = """
149 class A { 154 class A {
150 noSuchMethod(x, [y]) => super.noSuchMethod(x); 155 noSuchMethod(x, [y]) => super.noSuchMethod(x);
151 } 156 }
152 main() { 157 main() {
153 print(new A().foo()); 158 print(new A().foo());
154 } 159 }
155 """; 160 """;
156 Uri uri = new Uri(scheme: 'source'); 161 Uri uri = new Uri(scheme: 'source');
157 var compiler = compilerFor(source, uri); 162 var compiler = compilerFor(source, uri);
158 await compiler.run(uri); 163 asyncTest(() => compiler.run(uri).then((_) {
159 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 164 Expect.isFalse(compiler.backend.enabledNoSuchMethod);
160 ClassElement clsA = findElement(compiler, 'A'); 165 ClassElement clsA = findElement(compiler, 'A');
161 Expect.isTrue( 166 Expect.isTrue(
162 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( 167 compiler.backend.noSuchMethodRegistry.defaultImpls.contains(
163 clsA.lookupMember('noSuchMethod'))); 168 clsA.lookupMember('noSuchMethod')));
169 }));
164 } 170 }
165 171
166 Future dummyImplTest8() async { 172 dummyImplTest8() {
167 String source = """ 173 String source = """
168 class A { 174 class A {
169 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); 175 noSuchMethod(x, [y]) => super.noSuchMethod(x, y);
170 } 176 }
171 main() { 177 main() {
172 print(new A().foo()); 178 print(new A().foo());
173 } 179 }
174 """; 180 """;
175 Uri uri = new Uri(scheme: 'source'); 181 Uri uri = new Uri(scheme: 'source');
176 var compiler = compilerFor(source, uri); 182 var compiler = compilerFor(source, uri);
177 await compiler.run(uri); 183 asyncTest(() => compiler.run(uri).then((_) {
178 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 184 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
179 ClassElement clsA = findElement(compiler, 'A'); 185 ClassElement clsA = findElement(compiler, 'A');
180 Expect.isTrue( 186 Expect.isTrue(
181 compiler.backend.noSuchMethodRegistry.otherImpls.contains( 187 compiler.backend.noSuchMethodRegistry.otherImpls.contains(
182 clsA.lookupMember('noSuchMethod'))); 188 clsA.lookupMember('noSuchMethod')));
189 }));
183 } 190 }
184 191
185 Future dummyImplTest9() async { 192 dummyImplTest9() {
186 String source = """ 193 String source = """
187 class A { 194 class A {
188 noSuchMethod(x, y) => super.noSuchMethod(x); 195 noSuchMethod(x, y) => super.noSuchMethod(x);
189 } 196 }
190 main() { 197 main() {
191 print(new A().foo()); 198 print(new A().foo());
192 } 199 }
193 """; 200 """;
194 Uri uri = new Uri(scheme: 'source'); 201 Uri uri = new Uri(scheme: 'source');
195 var compiler = compilerFor(source, uri); 202 var compiler = compilerFor(source, uri);
196 await compiler.run(uri); 203 asyncTest(() => compiler.run(uri).then((_) {
197 Expect.isFalse(compiler.backend.enabledNoSuchMethod); 204 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
198 ClassElement clsA = findElement(compiler, 'A'); 205 ClassElement clsA = findElement(compiler, 'A');
199 Expect.isTrue( 206 Expect.isTrue(
200 compiler.backend.noSuchMethodRegistry.notApplicableImpls.contains( 207 compiler.backend.noSuchMethodRegistry.otherImpls.contains(
201 clsA.lookupMember('noSuchMethod'))); 208 clsA.lookupMember('noSuchMethod')));
209 }));
202 } 210 }
203 211
204 Future dummyImplTest10() async { 212 dummyImplTest10() {
205 String source = """ 213 String source = """
206 class A { 214 class A {
207 noSuchMethod(Invocation x) { 215 noSuchMethod(Invocation x) {
208 throw new UnsupportedException(); 216 throw new UnsupportedException();
209 } 217 }
210 } 218 }
211 main() { 219 main() {
212 print(new A().foo()); 220 print(new A().foo());
213 } 221 }
214 """; 222 """;
215 Uri uri = new Uri(scheme: 'source'); 223 Uri uri = new Uri(scheme: 'source');
216 var compiler = compilerFor(source, uri); 224 var compiler = compilerFor(source, uri);
217 await compiler.run(uri); 225 asyncTest(() => compiler.run(uri).then((_) {
218 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 226 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
219 ClassElement clsA = findElement(compiler, 'A'); 227 ClassElement clsA = findElement(compiler, 'A');
220 Expect.isTrue( 228 Expect.isTrue(
221 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( 229 compiler.backend.noSuchMethodRegistry.throwingImpls.contains(
222 clsA.lookupMember('noSuchMethod'))); 230 clsA.lookupMember('noSuchMethod')));
231 }));
223 } 232 }
224 233
225 Future dummyImplTest11() async { 234 dummyImplTest11() {
226 String source = """ 235 String source = """
227 class A { 236 class A {
228 noSuchMethod(Invocation x) { 237 noSuchMethod(Invocation x) {
229 print('foo'); 238 print('foo');
230 throw 'foo'; 239 throw 'foo';
231 } 240 }
232 } 241 }
233 main() { 242 main() {
234 print(new A().foo()); 243 print(new A().foo());
235 } 244 }
236 """; 245 """;
237 Uri uri = new Uri(scheme: 'source'); 246 Uri uri = new Uri(scheme: 'source');
238 var compiler = compilerFor(source, uri); 247 var compiler = compilerFor(source, uri);
239 await compiler.run(uri); 248 asyncTest(() => compiler.run(uri).then((_) {
240 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 249 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
241 ClassElement clsA = findElement(compiler, 'A'); 250 ClassElement clsA = findElement(compiler, 'A');
242 Expect.isTrue( 251 Expect.isTrue(
243 compiler.backend.noSuchMethodRegistry.otherImpls.contains( 252 compiler.backend.noSuchMethodRegistry.otherImpls.contains(
244 clsA.lookupMember('noSuchMethod'))); 253 clsA.lookupMember('noSuchMethod')));
245 Expect.isTrue( 254 Expect.isTrue(
246 compiler.backend.noSuchMethodRegistry.complexNoReturnImpls.contains( 255 compiler.backend.noSuchMethodRegistry.complexNoReturnImpls.contains(
247 clsA.lookupMember('noSuchMethod'))); 256 clsA.lookupMember('noSuchMethod')));
257 }));
248 } 258 }
249 259
250 Future dummyImplTest12() async { 260 dummyImplTest12() {
251 String source = """ 261 String source = """
252 class A { 262 class A {
253 noSuchMethod(Invocation x) { 263 noSuchMethod(Invocation x) {
254 return toString(); 264 return toString();
255 } 265 }
256 } 266 }
257 main() { 267 main() {
258 print(new A().foo()); 268 print(new A().foo());
259 } 269 }
260 """; 270 """;
261 Uri uri = new Uri(scheme: 'source'); 271 Uri uri = new Uri(scheme: 'source');
262 var compiler = compilerFor(source, uri); 272 var compiler = compilerFor(source, uri);
263 await compiler.run(uri); 273 asyncTest(() => compiler.run(uri).then((_) {
264 Expect.isTrue(compiler.backend.enabledNoSuchMethod); 274 Expect.isTrue(compiler.backend.enabledNoSuchMethod);
265 ClassElement clsA = findElement(compiler, 'A'); 275 ClassElement clsA = findElement(compiler, 'A');
266 Expect.isTrue( 276 Expect.isTrue(
267 compiler.backend.noSuchMethodRegistry.otherImpls.contains( 277 compiler.backend.noSuchMethodRegistry.otherImpls.contains(
268 clsA.lookupMember('noSuchMethod'))); 278 clsA.lookupMember('noSuchMethod')));
269 Expect.isTrue( 279 Expect.isTrue(
270 compiler.backend.noSuchMethodRegistry.complexReturningImpls.contains( 280 compiler.backend.noSuchMethodRegistry.complexReturningImpls.contains(
271 clsA.lookupMember('noSuchMethod'))); 281 clsA.lookupMember('noSuchMethod')));
282 }));
272 } 283 }
273 284
274 main() { 285 main() {
275 asyncTest(() async { 286 dummyImplTest();
276 await dummyImplTest(); 287 dummyImplTest2();
277 await dummyImplTest2(); 288 dummyImplTest3();
278 await dummyImplTest3(); 289 dummyImplTest4();
279 await dummyImplTest4(); 290 dummyImplTest5();
280 await dummyImplTest5(); 291 dummyImplTest6();
281 await dummyImplTest6(); 292 dummyImplTest7();
282 await dummyImplTest7(); 293 dummyImplTest8();
283 await dummyImplTest8(); 294 dummyImplTest9();
284 await dummyImplTest9(); 295 dummyImplTest10();
285 await dummyImplTest10(); 296 dummyImplTest11();
286 await dummyImplTest11(); 297 dummyImplTest12();
287 await dummyImplTest12();
288 });
289 } 298 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/semantic_visitor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698