| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; |
| 6 |
| 5 closure0() { | 7 closure0() { |
| 6 // f and g will both capture a variable named 'x'. If we use the original | 8 // f and g will both capture a variable named 'x'. If we use the original |
| 7 // name in the (shared) box then there will be troubles. | 9 // name in the (shared) box then there will be troubles. |
| 8 var f; | 10 var f; |
| 9 var g; | 11 var g; |
| 10 { | 12 { |
| 11 var x = 499; | 13 var x = 499; |
| 12 // TODO(floitsch): remove name from functions. | 14 // TODO(floitsch): remove name from functions. |
| 13 f = fun() { return x; }; | 15 f = fun() { return x; }; |
| 14 x++; | 16 x++; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 30 // TODO(floitsch): remove name from functions. | 32 // TODO(floitsch): remove name from functions. |
| 31 var f = fun() { return $1; }; | 33 var f = fun() { return $1; }; |
| 32 $1++; | 34 $1++; |
| 33 Expect.equals(500, f()); | 35 Expect.equals(500, f()); |
| 34 } | 36 } |
| 35 | 37 |
| 36 main() { | 38 main() { |
| 37 closure0(); | 39 closure0(); |
| 38 closure1(); | 40 closure1(); |
| 39 } | 41 } |
| OLD | NEW |