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

Side by Side Diff: tests/language/rewrite_swap.dart

Issue 312793002: dart2dart: Preserve variable names throughout the IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Properly linearize phi assignments, remove unused write count 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 swap1(x,y,b) {
8 if (b) {
9 var t = x;
10 x = y;
11 y = t;
12 }
13 Expect.equals(2, x);
14 Expect.equals(1, y);
15 }
16
17 swap2(x,y,z,w,b) {
18 if (b) {
19 var t = x;
20 x = y;
21 y = t;
22
23 var q = z;
24 z = w;
25 w = q;
26 }
27 Expect.equals(2, x);
28 Expect.equals(1, y);
29 Expect.equals(4, z);
30 Expect.equals(3, w);
31 }
32
33 swap3(x,y,z,b) {
34 if (b) {
35 var t = x;
36 x = y;
37 y = z;
38 z = t;
39 }
40 Expect.equals(2, x);
41 Expect.equals(3, y);
42 Expect.equals(1, z);
43 }
44
45 swap4(x,y,z,b) {
46 if (b) {
47 var t = x;
48 x = y;
49 y = z; // swap cycle involves unused variable 'y'
50 z = t;
51 }
52 Expect.equals(2, x);
53 Expect.equals(1, z);
54 }
55
56 main() {
57 swap1(1,2,true);
58 swap1(2,1,false);
59
60 swap2(1,2,3,4,true);
61 swap2(2,1,4,3,false);
62
63 swap3(1,2,3,true);
64 swap3(2,3,1,false);
65
66 swap4(1,2,3,true);
67 swap4(2,3,1,false);
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698