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

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

Issue 725293004: Add support for if, while, break, continue to js-cps (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years, 1 month 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_control_flow.dart
diff --git a/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart b/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e542451c942a60a3635df82f4031146d763c1e62
--- /dev/null
+++ b/tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart
@@ -0,0 +1,114 @@
+// 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 control flow statements.
+
+library control_flow_tests;
+
+import 'js_backend_cps_ir_test.dart';
+
+const List<TestEntry> tests = const [
+ const TestEntry("""
+main() {
+ while (true);
+}
+""", """
+function() {
+ while (true)
+ ;
+}"""),
+ const TestEntry("""
+foo(a) => a;
+
+main() {
+ while (true) {
+ l: while (true) {
+ while (foo(true)) {
+ if (foo(false)) break l;
+ }
+ print(1);
+ }
+ print(2);
+ }
+}
+""", """
+function() {
+ L0:
+ while (true)
+ while (true) {
+ while (P.identical(V.foo(true), true))
+ if (P.identical(V.foo(false), true)) {
+ P.print(2);
+ continue L0;
+ }
+ P.print(1);
+ }
+}"""),
+ const TestEntry("""
+foo(a) => a;
+
+main() {
+ for (int i = 0; foo(true); i = foo(i)) {
+ print(1);
+ if (foo(false)) break;
+ }
+ print(2);
+}""", """
+function() {
+ var i;
+ i = 0;
+ L1:
+ while (true) {
+ if (P.identical(V.foo(true), true)) {
+ P.print(1);
+ if (!P.identical(V.foo(false), true)) {
+ i = V.foo(i);
+ continue L1;
+ }
+ }
+ P.print(2);
+ return null;
+ }
+}"""),
+const TestEntry("""
+foo(a) => a;
+
+main() {
+ if (foo(true)) {
+ print(1);
+ } else {
+ print(2);
+ }
+ print(3);
+}""", """
+function() {
+ P.identical(V.foo(true), true) ? P.print(1) : P.print(2);
+ P.print(3);
+ return null;
+}"""),
+const TestEntry("""
+foo(a) => a;
+
+main() {
+ if (foo(true)) {
+ print(1);
+ print(1);
+ } else {
+ print(2);
+ print(2);
+ }
+ print(3);
+}""", """
+function() {
+ if (P.identical(V.foo(true), true)) {
+ P.print(1);
+ P.print(1);
+ } else {
+ P.print(2);
+ P.print(2);
+ }
+ P.print(3);
+ return null;
+}"""),
+];
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698