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

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

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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:expect/expect.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import "package:async_helper/async_helper.dart"; 8 import 'package:compiler/src/dart2jslib.dart';
9 import 'memory_source_file_helper.dart';
10
11 import 'package:compiler/src/dart2jslib.dart'
12 show NullSink;
13
14 import 'package:compiler/compiler.dart'
15 show Diagnostic;
16
17 import 'dart:async';
18 import 'package:compiler/src/js_backend/js_backend.dart' 9 import 'package:compiler/src/js_backend/js_backend.dart'
19 show JavaScriptBackend; 10 show JavaScriptBackend;
11 import 'package:expect/expect.dart';
12 import 'memory_compiler.dart';
20 13
21 main() { 14 main() {
22 Uri script = currentDirectory.resolveUri(Platform.script); 15 DiagnosticCollector collector = new DiagnosticCollector();
23 Uri libraryRoot = script.resolve('../../../sdk/'); 16 Compiler compiler = compilerFor(
24 Uri packageRoot = script.resolve('./packages/'); 17 MEMORY_SOURCE_FILES, diagnosticHandler: collector);
25
26 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
27 void diagnosticHandler(Uri uri, int begin, int end,
28 String message, Diagnostic kind) {
29 if (kind == Diagnostic.VERBOSE_INFO
30 || kind == Diagnostic.WARNING
31 || kind == Diagnostic.HINT) {
32 return;
33 }
34 throw '$uri:$begin:$end:$message:$kind';
35 }
36
37 EventSink<String> outputProvider(String name, String extension) {
38 return new NullSink('$name.$extension');
39 }
40
41 Compiler compiler = new Compiler(provider.readStringFromUri,
42 outputProvider,
43 diagnosticHandler,
44 libraryRoot,
45 packageRoot,
46 [],
47 {});
48 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { 18 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
19 Expect.isTrue(collector.errors.isEmpty);
20 Expect.isTrue(collector.infos.isEmpty);
49 Expect.isFalse(compiler.compilationFailed); 21 Expect.isFalse(compiler.compilationFailed);
50 Expect.isFalse(compiler.enqueuer.resolution.hasEnqueuedReflectiveElements); 22 Expect.isFalse(compiler.enqueuer.resolution.hasEnqueuedReflectiveElements);
51 Expect.isFalse(compiler.enqueuer.resolution.hasEnqueuedReflectiveStaticField s); 23 Expect.isFalse(
24 compiler.enqueuer.resolution.hasEnqueuedReflectiveStaticFields);
52 Expect.isFalse(compiler.enqueuer.codegen.hasEnqueuedReflectiveElements); 25 Expect.isFalse(compiler.enqueuer.codegen.hasEnqueuedReflectiveElements);
53 Expect.isFalse(compiler.enqueuer.codegen.hasEnqueuedReflectiveStaticFields); 26 Expect.isFalse(compiler.enqueuer.codegen.hasEnqueuedReflectiveStaticFields);
54 Expect.isFalse(compiler.disableTypeInference); 27 Expect.isFalse(compiler.disableTypeInference);
55 JavaScriptBackend backend = compiler.backend; 28 JavaScriptBackend backend = compiler.backend;
56 Expect.isFalse(backend.hasRetainedMetadata); 29 Expect.isFalse(backend.hasRetainedMetadata);
57 })); 30 }));
58 } 31 }
59 32
60 const Map MEMORY_SOURCE_FILES = const { 33 const Map MEMORY_SOURCE_FILES = const {
61 'main.dart': r""" 34 'main.dart': r"""
62 import 'dart:mirrors'; 35 import 'dart:mirrors';
63 36
64 class Foo { 37 class Foo {
65 noSuchMethod(invocation) { 38 noSuchMethod(invocation) {
66 print('Invoked ${MirrorSystem.getName(invocation.memberName)}'); 39 print('Invoked ${MirrorSystem.getName(invocation.memberName)}');
67 return reflect('foobar').delegate(invocation); 40 return reflect('foobar').delegate(invocation);
68 } 41 }
69 } 42 }
70 43
71 void main() { 44 void main() {
72 print(new Foo().substring(3)); 45 print(new Foo().substring(3));
73 } 46 }
74 """, 47 """,
75 }; 48 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/message_kind_helper.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698