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

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

Issue 1310483004: Redo "Inline single-use local closures." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: test updates Created 5 years, 3 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 // Tests of closures. 5 // Tests of closures.
6 6
7 library closures_test; 7 library closures_test;
8 8
9 import 'js_backend_cps_ir.dart'; 9 import 'js_backend_cps_ir.dart';
10 10
11 const List<TestEntry> tests = const [ 11 const List<TestEntry> tests = const [
12 const TestEntry(""" 12 const TestEntry("""
13 main(x) { 13 main(x) {
14 a() { 14 a() {
15 return x; 15 return x;
16 } 16 }
17 x = x + '1'; 17 x = x + '1';
18 print(a()); 18 print(a());
19 } 19 }
20 """, 20 """,
21 r""" 21 r"""
22 function(x) { 22 function(x) {
23 var _box_0 = {}; 23 var _box_0 = {};
24 _box_0._captured_x_0 = x; 24 _box_0._captured_x_0 = x;
25 _box_0._captured_x_0 = J.getInterceptor$ns(x = _box_0._captured_x_0).$add(x, " 1"); 25 _box_0._captured_x_0 = J.getInterceptor$ns(x = _box_0._captured_x_0).$add(x, " 1");
26 P.print(new V.main_a(_box_0).call$0()); 26 P.print(new V.main_a(_box_0)._box_0._captured_x_0);
27 }"""), 27 }"""),
28 28
29 const TestEntry(""" 29 const TestEntry("""
30 main(x) {
31 a() {
32 return x;
33 }
34 x = x + '1';
35 print(a());
36 return a;
37 }
38 """,
39 r"""
40 function(x) {
41 var _box_0 = {}, a = new V.main_a(_box_0);
42 _box_0._captured_x_0 = x;
43 _box_0._captured_x_0 = J.getInterceptor$ns(x = _box_0._captured_x_0).$add(x, " 1");
44 P.print(a.call$0());
45 return a;
46 }"""),
47
48 const TestEntry("""
30 main(x) { 49 main(x) {
31 a() { 50 a() {
32 return x; 51 return x;
33 } 52 }
34 print(a()); 53 print(a());
35 } 54 }
36 """, 55 """,
37 r""" 56 r"""
38 function(x) { 57 function(x) {
39 P.print(new V.main_a(x).call$0()); 58 P.print(new V.main_a(x)._captured_x_0);
40 }"""), 59 }"""),
41 60
42 const TestEntry(""" 61 const TestEntry("""
62 main(x) {
63 a() {
64 return x;
65 }
66 print(a());
67 return a;
68 }
69 """,
70 r"""
71 function(x) {
72 var a = new V.main_a(x);
73 P.print(a.call$0());
74 return a;
75 }"""),
76
77 const TestEntry("""
43 main() { 78 main() {
44 var x = 122; 79 var x = 122;
45 var a = () => x; 80 var a = () => x;
46 x = x + 1; 81 x = x + 1;
47 print(a()); 82 print(a());
48 } 83 }
49 """, 84 """,
50 r""" 85 r"""
51 function() { 86 function() {
52 var _box_0 = {}; 87 var _box_0 = {};
53 _box_0._captured_x_0 = 122; 88 _box_0._captured_x_0 = 122;
54 _box_0._captured_x_0 = _box_0._captured_x_0 + 1; 89 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
55 P.print(new V.main_closure(_box_0).call$0()); 90 P.print(new V.main_closure(_box_0)._box_0._captured_x_0);
56 }"""), 91 }"""),
57 92
58 const TestEntry(""" 93 const TestEntry("""
94 main() {
95 var x = 122;
96 var a = () => x;
97 x = x + 1;
98 print(a());
99 return a;
100 }
101 """,
102 r"""
103 function() {
104 var _box_0 = {}, a = new V.main_closure(_box_0);
105 _box_0._captured_x_0 = 122;
106 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
107 P.print(a.call$0());
108 return a;
109 }"""),
110
111 const TestEntry("""
59 main() { 112 main() {
60 var x = 122; 113 var x = 122;
61 var a = () { 114 var a = () {
62 var y = x; 115 var y = x;
63 return () => y; 116 return () => y;
64 }; 117 };
65 x = x + 1; 118 x = x + 1;
66 print(a()()); 119 print(a()());
67 } 120 }
68 """, 121 """,
69 r""" 122 r"""
70 function() { 123 function() {
71 var _box_0 = {}; 124 var _box_0 = {};
72 _box_0._captured_x_0 = 122; 125 _box_0._captured_x_0 = 122;
73 _box_0._captured_x_0 = _box_0._captured_x_0 + 1; 126 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
74 P.print(new V.main_closure(_box_0).call$0().call$0()); 127 P.print(new V.main__closure(new V.main_closure(_box_0)._box_0._captured_x_0)._ captured_y_1);
75 }"""), 128 }"""),
76 129
77 const TestEntry(""" 130 const TestEntry("""
131 main() {
132 var x = 122;
133 var a = () {
134 var y = x;
135 return () => y;
136 };
137 x = x + 1;
138 print(a()());
139 return a;
140 }
141 """,
142 r"""
143 function() {
144 var _box_0 = {}, a = new V.main_closure(_box_0);
145 _box_0._captured_x_0 = 122;
146 _box_0._captured_x_0 = _box_0._captured_x_0 + 1;
147 P.print(a.call$0().call$0());
148 return a;
149 }"""),
150
151 const TestEntry("""
78 main() { 152 main() {
79 var a; 153 var a;
80 for (var i=0; i<10; i++) { 154 for (var i=0; i<10; i++) {
81 a = () => i; 155 a = () => i;
82 } 156 }
83 print(a()); 157 print(a());
84 } 158 }
85 """, 159 """,
86 r""" 160 r"""
87 function() { 161 function() {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 """, 256 """,
183 r""" 257 r"""
184 function(x) { 258 function(x) {
185 P.print(V.Foo$().getter$1(123)); 259 P.print(V.Foo$().getter$1(123));
186 }"""), 260 }"""),
187 ]; 261 ];
188 262
189 void main() { 263 void main() {
190 runTests(tests); 264 runTests(tests);
191 } 265 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698