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

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

Issue 2748383003: Split MirrorsAnalysis (Closed)
Patch Set: Created 3 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 tree-shaking hasn't been turned off. 5 // Test that tree-shaking hasn't been turned off.
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/js_backend/js_backend.dart' show JavaScriptBackend; 9 import 'package:compiler/src/js_backend/js_backend.dart' show JavaScriptBackend;
10 import 'package:compiler/src/js_backend/mirrors_analysis.dart';
10 import 'package:expect/expect.dart'; 11 import 'package:expect/expect.dart';
11 import 'memory_compiler.dart'; 12 import 'memory_compiler.dart';
12 13
13 main() { 14 main() {
14 DiagnosticCollector collector = new DiagnosticCollector(); 15 DiagnosticCollector collector = new DiagnosticCollector();
15 asyncTest(() async { 16 asyncTest(() async {
16 CompilationResult result = await runCompiler( 17 CompilationResult result = await runCompiler(
17 memorySourceFiles: MEMORY_SOURCE_FILES, diagnosticHandler: collector); 18 memorySourceFiles: MEMORY_SOURCE_FILES, diagnosticHandler: collector);
18 Compiler compiler = result.compiler; 19 Compiler compiler = result.compiler;
19 JavaScriptBackend backend = compiler.backend; 20 JavaScriptBackend backend = compiler.backend;
20 Expect.isTrue(collector.errors.isEmpty); 21 Expect.isTrue(collector.errors.isEmpty);
21 Expect.isTrue(collector.infos.isEmpty); 22 Expect.isTrue(collector.infos.isEmpty);
22 Expect.isFalse(compiler.compilationFailed); 23 Expect.isFalse(compiler.compilationFailed);
23 Expect.isFalse(backend 24 MirrorsResolutionAnalysisImpl mirrorsResolutionAnalysis =
24 .mirrorsAnalysis.resolutionHandler.hasEnqueuedReflectiveElements); 25 backend.mirrorsResolutionAnalysis;
25 Expect.isFalse(backend
26 .mirrorsAnalysis.resolutionHandler.hasEnqueuedReflectiveStaticFields);
27 Expect.isFalse( 26 Expect.isFalse(
28 backend.mirrorsAnalysis.codegenHandler.hasEnqueuedReflectiveElements); 27 mirrorsResolutionAnalysis.handler.hasEnqueuedReflectiveElements);
29 Expect.isFalse(backend 28 Expect.isFalse(
30 .mirrorsAnalysis.codegenHandler.hasEnqueuedReflectiveStaticFields); 29 mirrorsResolutionAnalysis.handler.hasEnqueuedReflectiveStaticFields);
30 MirrorsCodegenAnalysisImpl mirrorsCodegenAnalysis =
31 backend.mirrorsCodegenAnalysis;
32 Expect
33 .isFalse(mirrorsCodegenAnalysis.handler.hasEnqueuedReflectiveElements);
34 Expect.isFalse(
35 mirrorsCodegenAnalysis.handler.hasEnqueuedReflectiveStaticFields);
31 Expect.isFalse(compiler.disableTypeInference); 36 Expect.isFalse(compiler.disableTypeInference);
32 Expect.isFalse(backend.mirrorsData.hasRetainedMetadata); 37 Expect.isFalse(backend.mirrorsData.hasRetainedMetadata);
33 }); 38 });
34 } 39 }
35 40
36 const Map MEMORY_SOURCE_FILES = const { 41 const Map MEMORY_SOURCE_FILES = const {
37 'main.dart': r""" 42 'main.dart': r"""
38 import 'dart:mirrors'; 43 import 'dart:mirrors';
39 44
40 class Foo { 45 class Foo {
41 noSuchMethod(invocation) { 46 noSuchMethod(invocation) {
42 print('Invoked ${MirrorSystem.getName(invocation.memberName)}'); 47 print('Invoked ${MirrorSystem.getName(invocation.memberName)}');
43 return reflect('foobar').delegate(invocation); 48 return reflect('foobar').delegate(invocation);
44 } 49 }
45 } 50 }
46 51
47 void main() { 52 void main() {
48 print(new Foo().substring(3)); 53 print(new Foo().substring(3));
49 } 54 }
50 """, 55 """,
51 }; 56 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/kernel/closed_world_test.dart ('k') | tests/compiler/dart2js/mirrors_used_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698