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

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

Issue 16817002: Be smarter about when disabling tree-shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 no parts are emitted when deferred loading isn't used. 5 // Test that no parts are emitted when deferred loading isn't used.
Johnni Winther 2013/06/13 07:08:29 Update comment.
ahe 2013/06/14 12:00:22 Done.
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'memory_source_file_helper.dart'; 8 import 'memory_source_file_helper.dart';
9 9
10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
11 show NullSink; 11 show NullSink;
12 12
13 import '../../../sdk/lib/_internal/compiler/compiler.dart' 13 import '../../../sdk/lib/_internal/compiler/compiler.dart'
14 show Diagnostic; 14 show Diagnostic;
15 15
16 import 'dart:async'; 16 import 'dart:async';
17 17
18 main() { 18 main() {
19 Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script)); 19 Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script));
20 Uri libraryRoot = script.resolve('../../../sdk/'); 20 Uri libraryRoot = script.resolve('../../../sdk/');
21 Uri packageRoot = script.resolve('./packages/'); 21 Uri packageRoot = script.resolve('./packages/');
22 22
23 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES; 23 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
24 var provider = new MemorySourceFileProvider(); 24 var provider = new MemorySourceFileProvider();
25 void diagnosticHandler(Uri uri, int begin, int end, 25 void diagnosticHandler(Uri uri, int begin, int end,
26 String message, Diagnostic kind) { 26 String message, Diagnostic kind) {
27 if (kind == Diagnostic.VERBOSE_INFO) { 27 if (kind == Diagnostic.VERBOSE_INFO || kind == Diagnostic.WARNING) {
28 return; 28 return;
29 } 29 }
30 throw '$uri:$begin:$end:$message:$kind'; 30 throw '$uri:$begin:$end:$message:$kind';
31 } 31 }
32 32
33 EventSink<String> outputProvider(String name, String extension) { 33 EventSink<String> outputProvider(String name, String extension) {
34 if (name != '') throw 'Attempt to output file "$name.$extension"';
35 return new NullSink('$name.$extension'); 34 return new NullSink('$name.$extension');
36 } 35 }
37 36
38 Compiler compiler = new Compiler(provider.readStringFromUri, 37 Compiler compiler = new Compiler(provider.readStringFromUri,
39 outputProvider, 38 outputProvider,
40 diagnosticHandler, 39 diagnosticHandler,
41 libraryRoot, 40 libraryRoot,
42 packageRoot, 41 packageRoot,
43 []); 42 []);
44 compiler.run(Uri.parse('memory:main.dart')); 43 compiler.run(Uri.parse('memory:main.dart'));
45 Expect.isFalse(compiler.compilationFailed); 44 Expect.isFalse(compiler.compilationFailed);
45 Expect.isFalse(compiler.enqueuer.resolution.hasEnqueuedEverything);
46 Expect.isFalse(compiler.enqueuer.codegen.hasEnqueuedEverything);
46 } 47 }
47 48
48 const Map MEMORY_SOURCE_FILES = const { 49 const Map MEMORY_SOURCE_FILES = const {
49 'main.dart': """ 50 'main.dart': r"""
50 class Greeting { 51 import 'dart:mirrors';
51 final message; 52
52 const Greeting(this.message); 53 class Foo {
54 noSuchMethod(invocation) {
55 print('Invoked ${MirrorSystem.getName(invocation.memberName)}');
56 return reflect('foobar').delegate(invocation);
57 }
53 } 58 }
54 59
55 const fisk = const Greeting('Hello, World!'); 60 void main() {
56 61 print(new Foo().substring(3));
57 main() {
58 var x = fisk;
59 if (new DateTime.now().millisecondsSinceEpoch == 42) {
60 x = new Greeting(\"I\'m confused\");
61 }
62 print(x.message);
63 } 62 }
64 """, 63 """,
65 }; 64 };
OLDNEW
« dart/sdk/lib/_internal/lib/js_mirrors.dart ('K') | « dart/sdk/lib/_internal/lib/js_mirrors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698