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

Side by Side Diff: tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart

Issue 918653002: Propagate pseudo-constants expressions separately in tree rewriter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=-DUSE_CPS_IR=true 4 // VMOptions=-DUSE_CPS_IR=true
5 5
6 // Tests of closures. 6 // Tests of closures.
7 7
8 library closures_test; 8 library closures_test;
9 9
10 import 'js_backend_cps_ir.dart'; 10 import 'js_backend_cps_ir.dart';
11 11
12 const List<TestEntry> tests = const [ 12 const List<TestEntry> tests = const [
13 const TestEntry(""" 13 const TestEntry("""
14 main(x) { 14 main(x) {
15 a() { 15 a() {
16 return x; 16 return x;
17 } 17 }
18 x = x + '1'; 18 x = x + '1';
19 print(a()); 19 print(a());
20 } 20 }
21 """, 21 """,
22 r""" 22 r"""
23 function(x) { 23 function(x) {
24 var box_0, a, v0; 24 var box_0, a;
25 box_0 = {}; 25 box_0 = {};
26 box_0.x_0 = x; 26 box_0.x_0 = x;
27 a = new V.main_a(box_0); 27 a = new V.main_a(box_0);
28 x = box_0.x_0; 28 x = box_0.x_0;
29 v0 = "1"; 29 box_0.x_0 = J.getInterceptor$ns(x).$add(x, "1");
30 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
31 P.print(a.call$0()); 30 P.print(a.call$0());
32 return null; 31 return null;
33 }"""), 32 }"""),
34 33
35 const TestEntry(""" 34 const TestEntry("""
36 main(x) { 35 main(x) {
37 a() { 36 a() {
38 return x; 37 return x;
39 } 38 }
40 print(a()); 39 print(a());
41 } 40 }
42 """, 41 """,
43 r""" 42 r"""
44 function(x) { 43 function(x) {
45 P.print(new V.main_a(x).call$0()); 44 P.print(new V.main_a(x).call$0());
46 return null; 45 return null;
47 }"""), 46 }"""),
48 47
49 const TestEntry(""" 48 const TestEntry("""
50 main() { 49 main() {
51 var x = 122; 50 var x = 122;
52 var a = () => x; 51 var a = () => x;
53 x = x + 1; 52 x = x + 1;
54 print(a()); 53 print(a());
55 } 54 }
56 """, 55 """,
57 r""" 56 r"""
58 function() { 57 function() {
59 var box_0, a, x, v0; 58 var box_0, a, x;
60 box_0 = {}; 59 box_0 = {};
61 box_0.x_0 = 122; 60 box_0.x_0 = 122;
62 a = new V.main_closure(box_0); 61 a = new V.main_closure(box_0);
63 x = box_0.x_0; 62 x = box_0.x_0;
64 v0 = 1; 63 box_0.x_0 = J.getInterceptor$ns(x).$add(x, 1);
65 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
66 P.print(a.call$0()); 64 P.print(a.call$0());
67 return null; 65 return null;
68 }"""), 66 }"""),
69 67
70 const TestEntry(""" 68 const TestEntry("""
71 main() { 69 main() {
72 var x = 122; 70 var x = 122;
73 var a = () { 71 var a = () {
74 var y = x; 72 var y = x;
75 return () => y; 73 return () => y;
76 }; 74 };
77 x = x + 1; 75 x = x + 1;
78 print(a()()); 76 print(a()());
79 } 77 }
80 """, 78 """,
81 r""" 79 r"""
82 function() { 80 function() {
83 var box_0, a, x, v0; 81 var box_0, a, x;
84 box_0 = {}; 82 box_0 = {};
85 box_0.x_0 = 122; 83 box_0.x_0 = 122;
86 a = new V.main_closure(box_0); 84 a = new V.main_closure(box_0);
87 x = box_0.x_0; 85 x = box_0.x_0;
88 v0 = 1; 86 box_0.x_0 = J.getInterceptor$ns(x).$add(x, 1);
89 box_0.x_0 = J.getInterceptor$ns(x).$add(x, v0);
90 P.print(a.call$0().call$0()); 87 P.print(a.call$0().call$0());
91 return null; 88 return null;
92 }"""), 89 }"""),
93 90
94 const TestEntry(""" 91 const TestEntry("""
95 main() { 92 main() {
96 var a; 93 var a;
97 for (var i=0; i<10; i++) { 94 for (var i=0; i<10; i++) {
98 a = () => i; 95 a = () => i;
99 } 96 }
100 print(a()); 97 print(a());
101 } 98 }
102 """, 99 """,
103 r""" 100 r"""
104 function() { 101 function() {
105 var a, i, v0, v1; 102 var a, i;
106 a = null; 103 a = null;
107 i = 0; 104 i = 0;
108 while (true) { 105 while (P.identical(J.getInterceptor$n(i).$lt(i, 10), true)) {
109 v0 = 10; 106 a = new V.main_closure(i);
110 if (P.identical(J.getInterceptor$n(i).$lt(i, v0), true)) { 107 i = J.getInterceptor$ns(i).$add(i, 1);
111 a = new V.main_closure(i);
112 v1 = 1;
113 i = J.getInterceptor$ns(i).$add(i, v1);
114 } else {
115 P.print(a.call$0());
116 return null;
117 }
118 } 108 }
109 P.print(a.call$0());
110 return null;
119 }"""), 111 }"""),
120 ]; 112 ];
121 113
122 void main() { 114 void main() {
123 runTests(tests); 115 runTests(tests);
124 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698