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

Side by Side Diff: tests/compiler/dart2js/closure/data/nested_closures.dart

Issue 3003543002: Add more tests for boxed variables. (Closed)
Patch Set: Created 3 years, 4 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 | « tests/compiler/dart2js/closure/data/mutations.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /*test:box=box0,boxed=[b1,b2,b3]*/ test(c1, /*boxed*/ b1) { 5 /// Test boxing/captures for nested closures.
6
7 /*useOne:box=box0,boxed=[b1]*/ useOne(/*boxed*/ b1) {
8 /*box=box1,boxed=[b2],free=[b1,box0]*/ () {
9 var /*boxed*/ b2 = (b1 = 1);
10
11 /*free=[b2,box1]*/ () {
12 return (b2 = 2);
13 };
14
15 return b2;
16 };
17 return b1;
18 }
19
20 /*useBoth:box=box0,boxed=[b1]*/ useBoth(/*boxed*/ b1) {
21 /*box=box1,boxed=[b2],free=[b1,box0]*/ () {
22 var /*boxed*/ b2 = (b1 = 1);
23
24 /*free=[b1,b2,box0,box1]*/ () {
25 return b1 + (b2 = 2);
26 };
27
28 return b2;
29 };
30 return b1;
31 }
32
33 /*useMany:box=box0,boxed=[b1,b2,b3]*/ useMany(c1, /*boxed*/ b1) {
6 var /*boxed*/ b2 = 2; 34 var /*boxed*/ b2 = 2;
7 var /*boxed*/ b3 = 3; 35 var /*boxed*/ b3 = 3;
8 var c2 = 2; 36 var c2 = 2;
9 var c3 = 3; 37 var c3 = 3;
10 /*box=box1,boxed=[b4],free=[b1,b2,b3,box0,c1,c2,c3]*/ () { 38 /*box=box1,boxed=[b4],free=[b1,b2,b3,box0,c1,c2,c3]*/ () {
11 var c4 = c1 + c2 + c3; 39 var c4 = c1 + c2 + c3;
12 var /*boxed*/ b4 = (b1 = 1) + (b2 = 2) + (b3 = 3); 40 var /*boxed*/ b4 = (b1 = 1) + (b2 = 2) + (b3 = 3);
13 41
14 /*free=[b1,b2,b4,box0,box1,c4]*/ () { 42 /*free=[b1,b2,b4,box0,box1,c4]*/ () {
15 return c4 + (b1 = 1) + (b2 = 2) + (b4 = 4); 43 return c4 + (b1 = 1) + (b2 = 2) + (b4 = 4);
16 }; 44 };
17 45
18 return b4; 46 return b4;
19 }; 47 };
20 return b1 + b2 + b3 + c1 + c2 + c3; 48 return b1 + b2 + b3 + c1 + c2 + c3;
21 } 49 }
22 50
23 main() { 51 main() {
24 test(1, 2); 52 useOne(1);
53 useBoth(1);
54 useMany(1, 2);
25 } 55 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/closure/data/mutations.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698