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

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

Issue 142793007: Test for Issue 16448 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « tests/compiler/dart2js/dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/simple_inferrer_const_closure_test.dart
diff --git a/tests/compiler/dart2js/simple_inferrer_const_closure_test.dart b/tests/compiler/dart2js/simple_inferrer_const_closure_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7b7be1a6da440c65728f34c064aa84760dbc9292
--- /dev/null
+++ b/tests/compiler/dart2js/simple_inferrer_const_closure_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2014, 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 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+import 'compiler_helper.dart';
+
+const String TEST = """
+
+method1() {
+ return 42;
+}
+
+method2(a) { // Called only via [foo2] with a small integer.
+ return a;
+}
+
+const foo1 = method1;
+const foo2 = method2;
+
+returnInt1() {
+ return foo1();
+}
+
+returnInt2() {
+ return foo2(54);
+}
+
+main() {
+ returnInt1();
+ returnInt2();
+}
+""";
+
+
+void main() {
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(TEST, uri);
+ asyncTest(() => compiler.runCompiler(uri).then((_) {
+ var typesInferrer = compiler.typesTask.typesInferrer;
+
+ checkReturn(String name, type) {
+ var element = findElement(compiler, name);
+ Expect.equals(type,
+ typesInferrer.getReturnTypeOfElement(element).simplify(compiler),
+ name);
+ }
+
+ checkReturn('method1', compiler.typesTask.uint31Type);
+ checkReturn('returnInt1', compiler.typesTask.uint31Type);
+
+ checkReturn('method2', compiler.typesTask.uint31Type);
+ checkReturn('returnInt2', compiler.typesTask.uint31Type);
+ }));
+}
« no previous file with comments | « tests/compiler/dart2js/dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698