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

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

Issue 1385183002: Revert "Avoid eager enqueueing from resolution" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/memory_compiler.dart ('k') | tests/compiler/dart2js/related_types.dart » ('j') | 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) 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';
10 import 'package:compiler/src/enqueue.dart';
11 import 'package:compiler/src/js_backend/js_backend.dart';
12 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
13 import 'memory_compiler.dart'; 10 import 'memory_compiler.dart';
14 11
15 main() { 12 main() {
16 asyncTest(() async { 13 asyncTest(() async {
17 await analyze('main() {}'); 14 await analyze('main() {}');
18 await analyze('main() => proxy;', proxyConstant: true); 15 await analyze('main() => proxy;', proxyConstant: true);
19 await analyze('@deprecated main() {}');
20 await analyze('@deprecated main() => deprecated;', deprecatedClass: true);
21 await analyze('main() => deprecated;', deprecatedClass: true);
22 }); 16 });
23 } 17 }
24 18
25 void checkInstantiated(Compiler compiler, ClassElement cls, bool expected) {
26 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
27 bool isInstantiated =
28 enqueuer.universe.directlyInstantiatedClasses.contains(cls);
29 bool isProcessed = enqueuer.isClassProcessed(cls);
30 Expect.equals(expected, isInstantiated,
31 'Unexpected instantiation state of class $cls.');
32 Expect.equals(expected, isProcessed,
33 'Unexpected processing state of class $cls.');
34 }
35
36 analyze(String code, 19 analyze(String code,
37 {bool proxyConstant: false, 20 {bool proxyConstant: false}) async {
38 bool deprecatedClass: false}) async {
39 CompilationResult result = await runCompiler( 21 CompilationResult result = await runCompiler(
40 memorySourceFiles: {'main.dart': code}, 22 memorySourceFiles: {'main.dart': code},
41 options: ['--analyze-only']); 23 options: ['--analyze-only']);
42 Expect.isTrue(result.isSuccess); 24 Expect.isTrue(result.isSuccess);
43 Compiler compiler = result.compiler; 25 Compiler compiler = result.compiler;
44 Expect.equals(proxyConstant, compiler.proxyConstant != null, 26 Expect.equals(proxyConstant, compiler.proxyConstant != null);
45 "Unexpected computation of proxy constant.");
46
47 checkInstantiated(
48 compiler, compiler.coreLibrary.find('_Proxy'), proxyConstant);
49 checkInstantiated(
50 compiler, compiler.coreLibrary.find('Deprecated'), deprecatedClass);
51
52 LibraryElement jsHelperLibrary =
53 compiler.libraryLoader.lookupLibrary(JavaScriptBackend.DART_JS_HELPER);
54 jsHelperLibrary.forEachLocalMember((Element element) {
55 Uri uri = element.compilationUnit.script.resourceUri;
56 if (element.isClass && uri.path.endsWith('annotations.dart')) {
57 checkInstantiated(compiler, element, false);
58 }
59 });
60 } 27 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/related_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698