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

Unified Diff: tests/compiler/dart2js/top_level_closure_tree_shake_test.dart

Issue 1211223002: Mark static function getters as used in codegen. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: add test Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/top_level_closure_tree_shake_test.dart
diff --git a/tests/compiler/dart2js/top_level_closure_tree_shake_test.dart b/tests/compiler/dart2js/top_level_closure_tree_shake_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6c3ae37a0e688c5814c82f10f5349baebf4f1ae6
--- /dev/null
+++ b/tests/compiler/dart2js/top_level_closure_tree_shake_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'compiler_helper.dart';
+
+const String TEST_ONE = r"""
+main() {
+ var f = use;
+ if (false) {
+ // This statement and the use of 'foo' should be optimized away, causing
+ // 'foo' to be absent from the final code.
+ f(foo);
+ }
+ f(bar);
+}
+
+foo() => 'Tarantula!';
+bar() => 'Coelacanth!';
+
+use(x) {
+ print(x());
+}
+""";
+
+
+main() {
+ asyncTest(() => Future.wait([
+ compileAll(TEST_ONE).then((String generated) {
+ Expect.isFalse(generated.contains('Tarantula!'),
+ "failed to remove 'foo'");
+ Expect.isTrue(generated.contains('Coelacanth!'));
+ }),
+ ]));
+}
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698