| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |