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

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

Issue 831133004: Use closure conversion in new dart2js backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
Index: tests/compiler/dart2js/js_backend_cps_ir_closures.dart
diff --git a/tests/compiler/dart2js/js_backend_cps_ir_closures.dart b/tests/compiler/dart2js/js_backend_cps_ir_closures.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2e18e304acc63b061dd0f636a8fc74d921e937df
--- /dev/null
+++ b/tests/compiler/dart2js/js_backend_cps_ir_closures.dart
@@ -0,0 +1,125 @@
+// 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.
+
+// Tests of interceptors.
+
+library closures_test;
+
+import 'js_backend_cps_ir_test.dart';
+
+const List<TestEntry> tests = const [
+ const TestEntry("""
+main(x) {
+ a() {
+ return x;
+ }
+ x = x + '1';
+ print(a());
+}
+""",
+r"""
+function(x) {
+ var box_0, a, v0;
+ box_0 = {};
+ box_0.x_0 = x;
+ a = new V.main_a(box_0);
+ x = box_0.x_0;
+ v0 = "1";
+ box_0.x_0 = J.getInterceptor(x).$add(x, v0);
+ P.print(a.call$0());
+ return null;
+}"""),
+
+ const TestEntry("""
+main(x) {
+ a() {
+ return x;
+ }
+ print(a());
+}
+""",
+r"""
+function(x) {
+ P.print(new V.main_a(x).call$0());
+ return null;
+}"""),
+
+ const TestEntry("""
+main() {
+ var x = 122;
+ var a = () => x;
+ x = x + 1;
+ print(a());
+}
+""",
+r"""
+function() {
+ var box_0, a, x, v0;
+ box_0 = {};
+ box_0.x_0 = 122;
+ a = new V.main_closure(box_0);
+ x = box_0.x_0;
+ v0 = 1;
+ box_0.x_0 = J.getInterceptor(x).$add(x, v0);
+ P.print(a.call$0());
+ return null;
+}"""),
+
+ const TestEntry("""
+main() {
+ var x = 122;
+ var a = () {
+ var y = x;
+ return () => y;
+ };
+ x = x + 1;
+ print(a()());
+}
+""",
+r"""
+function() {
+ var box_0, a, x, v0;
+ box_0 = {};
+ box_0.x_0 = 122;
+ a = new V.main_closure(box_0);
+ x = box_0.x_0;
+ v0 = 1;
+ box_0.x_0 = J.getInterceptor(x).$add(x, v0);
+ P.print(a.call$0().call$0());
+ return null;
+}"""),
+
+ const TestEntry("""
+main() {
+ var a;
+ for (var i=0; i<10; i++) {
+ a = () => i;
+ }
+ print(a());
+}
+""",
+r"""
+function() {
+ var a, box_0, i, v0, box_01, v1;
+ a = null;
+ box_0 = {};
+ box_0.i_0 = 0;
+ while (true) {
+ i = box_0.i_0;
+ v0 = 10;
+ if (P.identical(J.getInterceptor(i).$lt(i, v0), true)) {
+ a = new V.main_closure(box_0);
+ box_01 = {};
+ box_01.i_0 = box_0.i_0;
+ i = box_01.i_0;
+ v1 = 1;
+ box_01.i_0 = J.getInterceptor(i).$add(i, v1);
+ box_0 = box_01;
+ } else {
+ P.print(a.call$0());
+ return null;
+ }
+ }
+}"""),
+];

Powered by Google App Engine
This is Rietveld 408576698