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

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

Issue 2535143003: More refactoring of enqueuers (Closed)
Patch Set: Created 4 years 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 // Test that elements are not needlessly required by dart2js. 5 // Test that elements are not needlessly required by dart2js.
6 6
7 import 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:compiler/src/compiler.dart'; 8 import 'package:compiler/src/compiler.dart';
9 import 'package:compiler/src/elements/elements.dart'; 9 import 'package:compiler/src/elements/elements.dart';
10 import 'package:compiler/src/enqueue.dart'; 10 import 'package:compiler/src/enqueue.dart';
11 import 'package:compiler/src/js_backend/backend_helpers.dart'; 11 import 'package:compiler/src/js_backend/backend_helpers.dart';
12 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
13 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
14 14
15 main() { 15 main() {
16 asyncTest(() async { 16 asyncTest(() async {
17 await analyze('main() {}'); 17 await analyze('main() {}');
18 await analyze('main() => proxy;', proxyConstantComputed: true); 18 await analyze('main() => proxy;', proxyConstantComputed: true);
19 await analyze('@deprecated main() {}'); 19 await analyze('@deprecated main() {}');
20 await analyze('@deprecated main() => deprecated;', deprecatedClass: true); 20 await analyze('@deprecated main() => deprecated;', deprecatedClass: true);
21 await analyze('main() => deprecated;', deprecatedClass: true); 21 await analyze('main() => deprecated;', deprecatedClass: true);
22 }); 22 });
23 } 23 }
24 24
25 void checkInstantiated(Compiler compiler, ClassElement cls, bool expected) { 25 void checkInstantiated(Compiler compiler, ClassElement cls, bool expected) {
26 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution; 26 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
27 bool isInstantiated = 27 bool isInstantiated =
28 enqueuer.universe.directlyInstantiatedClasses.contains(cls); 28 enqueuer.universe.directlyInstantiatedClasses.contains(cls);
29 bool isProcessed = enqueuer.isClassProcessed(cls); 29 bool isProcessed = enqueuer.processedClasses.contains(cls);
30 Expect.equals(expected, isInstantiated, 30 Expect.equals(expected, isInstantiated,
31 'Unexpected instantiation state of class $cls.'); 31 'Unexpected instantiation state of class $cls.');
32 Expect.equals( 32 Expect.equals(
33 expected, isProcessed, 'Unexpected processing state of class $cls.'); 33 expected, isProcessed, 'Unexpected processing state of class $cls.');
34 } 34 }
35 35
36 analyze(String code, 36 analyze(String code,
37 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async { 37 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async {
38 CompilationResult result = await runCompiler( 38 CompilationResult result = await runCompiler(
39 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']); 39 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']);
(...skipping 13 matching lines...) Expand all
53 53
54 LibraryElement jsHelperLibrary = 54 LibraryElement jsHelperLibrary =
55 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER); 55 compiler.libraryLoader.lookupLibrary(BackendHelpers.DART_JS_HELPER);
56 jsHelperLibrary.forEachLocalMember((Element element) { 56 jsHelperLibrary.forEachLocalMember((Element element) {
57 Uri uri = element.compilationUnit.script.resourceUri; 57 Uri uri = element.compilationUnit.script.resourceUri;
58 if (element.isClass && uri.path.endsWith('annotations.dart')) { 58 if (element.isClass && uri.path.endsWith('annotations.dart')) {
59 checkInstantiated(compiler, element, false); 59 checkInstantiated(compiler, element, false);
60 } 60 }
61 }); 61 });
62 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698