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

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

Issue 2875313002: Access BackendUsage through ClosedWorld (Closed)
Patch Set: Created 3 years, 7 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'; 5 import 'dart:async';
6 import 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'package:compiler/src/common_elements.dart'; 7 import 'package:compiler/src/common_elements.dart';
8 import 'package:compiler/src/compiler.dart'; 8 import 'package:compiler/src/compiler.dart';
9 import 'package:compiler/src/elements/entities.dart'; 9 import 'package:compiler/src/elements/entities.dart';
10 import 'package:compiler/src/js_backend/no_such_method_registry.dart'; 10 import 'package:compiler/src/js_backend/no_such_method_registry.dart';
11 import 'package:compiler/src/world.dart';
11 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
12 import 'kernel/compiler_helper.dart'; 13 import 'kernel/compiler_helper.dart';
13 import 'compiler_helper.dart'; 14 import 'compiler_helper.dart';
14 15
15 class NoSuchMethodInfo { 16 class NoSuchMethodInfo {
16 final String className; 17 final String className;
17 final String superClassName; 18 final String superClassName;
18 final bool hasThrowingSyntax; 19 final bool hasThrowingSyntax;
19 final bool hasForwardingSyntax; 20 final bool hasForwardingSyntax;
20 final bool isThrowing; 21 final bool isThrowing;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 for (NoSuchMethodTest test in TESTS) { 253 for (NoSuchMethodTest test in TESTS) {
253 sources.add(test.code); 254 sources.add(test.code);
254 } 255 }
255 256
256 print('---- preparing for kernel tests ----------------------------------'); 257 print('---- preparing for kernel tests ----------------------------------');
257 List<CompileFunction> results = await compileMultiple(sources); 258 List<CompileFunction> results = await compileMultiple(sources);
258 for (int index = 0; index < results.length; index++) { 259 for (int index = 0; index < results.length; index++) {
259 print('---- testing with kernel --------------------------------------'); 260 print('---- testing with kernel --------------------------------------');
260 print(sources[index]); 261 print(sources[index]);
261 Compiler compiler = await results[index](); 262 Compiler compiler = await results[index]();
263 compiler.resolutionWorldBuilder.closeWorld();
262 // Complex returns are computed during inference. 264 // Complex returns are computed during inference.
263 checkTest(compiler, TESTS[index], testComplexReturns: false); 265 checkTest(compiler, TESTS[index], testComplexReturns: false);
264 } 266 }
265 }); 267 });
266 } 268 }
267 269
268 checkTest(Compiler compiler, NoSuchMethodTest test, {bool testComplexReturns}) { 270 checkTest(Compiler compiler, NoSuchMethodTest test, {bool testComplexReturns}) {
269 ElementEnvironment elementEnvironment = compiler.elementEnvironment; 271 ElementEnvironment elementEnvironment = compiler.elementEnvironment;
270 NoSuchMethodRegistry registry = compiler.backend.noSuchMethodRegistry; 272 NoSuchMethodRegistry registry = compiler.backend.noSuchMethodRegistry;
271 NoSuchMethodResolver resolver = registry.internalResolverForTesting; 273 NoSuchMethodResolver resolver = registry.internalResolverForTesting;
272 FunctionEntity ObjectNSM = elementEnvironment.lookupClassMember( 274 FunctionEntity ObjectNSM = elementEnvironment.lookupClassMember(
273 compiler.commonElements.objectClass, 'noSuchMethod'); 275 compiler.commonElements.objectClass, 'noSuchMethod');
276 ClosedWorld closedWorld =
277 compiler.resolutionWorldBuilder.closedWorldForTesting;
274 278
275 // Test [NoSuchMethodResolver] results for each method. 279 // Test [NoSuchMethodResolver] results for each method.
276 for (NoSuchMethodInfo info in test.methods) { 280 for (NoSuchMethodInfo info in test.methods) {
277 ClassEntity cls = 281 ClassEntity cls =
278 elementEnvironment.lookupClass(compiler.mainApp, info.className); 282 elementEnvironment.lookupClass(compiler.mainApp, info.className);
279 Expect.isNotNull(cls, "Class ${info.className} not found."); 283 Expect.isNotNull(cls, "Class ${info.className} not found.");
280 FunctionEntity noSuchMethod = 284 FunctionEntity noSuchMethod =
281 elementEnvironment.lookupClassMember(cls, 'noSuchMethod'); 285 elementEnvironment.lookupClassMember(cls, 'noSuchMethod');
282 Expect.isNotNull(noSuchMethod, "noSuchMethod not found in $cls."); 286 Expect.isNotNull(noSuchMethod, "noSuchMethod not found in $cls.");
283 287
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 "Unexpected isComplexNoReturn result on $noSuchMethod."); 342 "Unexpected isComplexNoReturn result on $noSuchMethod.");
339 Expect.equals( 343 Expect.equals(
340 info.isComplexReturn, 344 info.isComplexReturn,
341 registry.complexReturningImpls.contains(noSuchMethod), 345 registry.complexReturningImpls.contains(noSuchMethod),
342 "Unexpected isComplexReturn result on $noSuchMethod."); 346 "Unexpected isComplexReturn result on $noSuchMethod.");
343 } 347 }
344 } 348 }
345 349
346 Expect.equals( 350 Expect.equals(
347 test.isNoSuchMethodUsed, 351 test.isNoSuchMethodUsed,
348 compiler.backend.backendUsage.isNoSuchMethodUsed, 352 closedWorld.backendUsage.isNoSuchMethodUsed,
349 "Unexpected isNoSuchMethodUsed result."); 353 "Unexpected isNoSuchMethodUsed result.");
350 } 354 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/kernel/closed_world_test.dart ('k') | tests/compiler/dart2js/serialization/model_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698