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

Side by Side Diff: tests/language/src/FunctionTest.dart

Issue 9921030: Fix capturing of for-loop variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « tests/language/src/For2Test.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 function statements and expressions. 5 // Tests function statements and expressions.
6 6
7 class Bug4089219 { 7 class Bug4089219 {
8 int x; 8 int x;
9 var f; 9 var f;
10 10
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 x:for (int i = 0; i < 10; i++) { 204 x:for (int i = 0; i < 10; i++) {
205 a.add(() {return i;}); 205 a.add(() {return i;});
206 continue x; 206 continue x;
207 } 207 }
208 208
209 var sum = 0; 209 var sum = 0;
210 for (int i = 0; i < a.length; i++) { 210 for (int i = 0; i < a.length; i++) {
211 sum += (a[i])(); 211 sum += (a[i])();
212 } 212 }
213 213
214 Expect.equals(100, sum); 214 Expect.equals(45, sum);
215 } 215 }
216 216
217 int tempField; 217 int tempField;
218 218
219 // Validate that a closure that calls the private name of a function (for 219 // Validate that a closure that calls the private name of a function (for
220 // for recursion) calls the version of function with the bound names. 220 // for recursion) calls the version of function with the bound names.
221 void testRecursiveClosureRef() { 221 void testRecursiveClosureRef() {
222 tempField = 2; 222 tempField = 2;
223 var x = 3; 223 var x = 3;
224 var g = f(a) { 224 var g = f(a) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 fooIntString = foo; 349 fooIntString = foo;
350 350
351 uf = uf2; 351 uf = uf2;
352 uf2 = uf; 352 uf2 = uf;
353 } 353 }
354 } 354 }
355 355
356 main() { 356 main() {
357 FunctionTest.testMain(); 357 FunctionTest.testMain();
358 } 358 }
OLDNEW
« no previous file with comments | « tests/language/src/For2Test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698