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

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

Issue 12385076: Infer types of catpured variables and use the types in the SSA builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
Index: tests/compiler/dart2js/types_of_captured_variables_test.dart
===================================================================
--- tests/compiler/dart2js/types_of_captured_variables_test.dart (revision 0)
+++ tests/compiler/dart2js/types_of_captured_variables_test.dart (revision 0)
@@ -0,0 +1,48 @@
+// 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 'compiler_helper.dart';
+
+const String TEST1 = r"""
+main() {
+ var a = 52;
+ var f = () => a + 3;
kasperl 2013/03/05 08:26:44 Is this different than f() => a + 3;
ngeoffray 2013/03/05 09:02:31 Not for the analysis.
+ f();
+}
+""";
+
+const String TEST2 = r"""
+main() {
+ var a = 52;
+ var g = () { a = 48; };
+ var f = () => a + 3;
+ f();
+ g();
+}
+""";
+
+const String TEST3 = r"""
+main() {
+ var a = 52;
+ var g = () { a = 'foo'; };
+ var f = () => a + 3;
+ f();
+ g();
+}
+""";
+
+main() {
+ // Test that we know the type of captured, non-mutated variables.
+ String generated = compileAll(TEST1);
+ Expect.isTrue(generated.contains('+ 3'));
+
+ // Test that we know the type of captured, mutated variables.
+ generated = compileAll(TEST2);
+ Expect.isTrue(generated.contains('+ 3'));
+
+ // Test that we know when types of a captured, mutated variable
+ // conflict.
+ generated = compileAll(TEST3);
+ Expect.isFalse(generated.contains('+ 3'));
+}

Powered by Google App Engine
This is Rietveld 408576698