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

Side by Side 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 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 swap5(x,y,z,w,b,b2) {
57 if (b) {
58 var t = x;
59 x = y;
60 y = t;
61 }
62 if (b2) {
63 var q = z;
64 z = w;
65 w = q;
66 }
67 Expect.equals(2, x);
68 Expect.equals(1, y);
69 Expect.equals(4, z);
70 Expect.equals(3, w);
71 }
72
73 main() {
74 swap1(1,2,true);
75 swap1(2,1,false);
76
77 swap2(1,2,3,4,true);
78 swap2(2,1,4,3,false);
79
80 swap3(1,2,3,true);
81 swap3(2,3,1,false);
82
83 swap4(1,2,3,true);
84 swap4(2,3,1,false);
85
86 swap5(1,2,3,4,true, true);
87 swap5(1,2,4,3,true, false);
88 swap5(2,1,3,4,false, true);
89 swap5(2,1,4,3,false, false);
90 }
OLDNEW
« 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