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

Unified Diff: tests/language/rewrite_swap_test.dart

Issue 312793002: dart2dart: Preserve variable names throughout the IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: SVN rebase Created 6 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
Index: tests/language/rewrite_swap_test.dart
diff --git a/tests/language/rewrite_swap_test.dart b/tests/language/rewrite_swap_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..acb4e8f662ca3bacdeb905f1f2db471c599b7879
--- /dev/null
+++ b/tests/language/rewrite_swap_test.dart
@@ -0,0 +1,90 @@
+// 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";
+
+swap1(x,y,b) {
+ if (b) {
+ var t = x;
+ x = y;
+ y = t;
+ }
+ Expect.equals(2, x);
+ Expect.equals(1, y);
+}
+
+swap2(x,y,z,w,b) {
+ if (b) {
+ var t = x;
+ x = y;
+ y = t;
+
+ var q = z;
+ z = w;
+ w = q;
+ }
+ Expect.equals(2, x);
+ Expect.equals(1, y);
+ Expect.equals(4, z);
+ Expect.equals(3, w);
+}
+
+swap3(x,y,z,b) {
+ if (b) {
+ var t = x;
+ x = y;
+ y = z;
+ z = t;
+ }
+ Expect.equals(2, x);
+ Expect.equals(3, y);
+ Expect.equals(1, z);
+}
+
+swap4(x,y,z,b) {
+ if (b) {
+ var t = x;
+ x = y;
+ y = z; // swap cycle involves unused variable 'y'
+ z = t;
+ }
+ Expect.equals(2, x);
+ Expect.equals(1, z);
+}
+
+swap5(x,y,z,w,b,b2) {
+ if (b) {
+ var t = x;
+ x = y;
+ y = t;
+ }
+ if (b2) {
+ var q = z;
+ z = w;
+ w = q;
+ }
+ Expect.equals(2, x);
+ Expect.equals(1, y);
+ Expect.equals(4, z);
+ Expect.equals(3, w);
+}
+
+main() {
+ swap1(1,2,true);
+ swap1(2,1,false);
+
+ swap2(1,2,3,4,true);
+ swap2(2,1,4,3,false);
+
+ swap3(1,2,3,true);
+ swap3(2,3,1,false);
+
+ swap4(1,2,3,true);
+ swap4(2,3,1,false);
+
+ swap5(1,2,3,4,true, true);
+ swap5(1,2,4,3,true, false);
+ swap5(2,1,3,4,false, true);
+ swap5(2,1,4,3,false, false);
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/ir_tracer.dart ('k') | tests/language/rewrite_variable_initializer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698