| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 // Test that using a field or a global variable for a for/in variable |
| 6 // works. |
| 7 |
| 8 import "package:expect/expect.dart"; |
| 9 |
| 10 Set<int> set = new Set.from([1, 2]); |
| 11 var x; |
| 12 |
| 13 class A { |
| 14 var field; |
| 15 test() { |
| 16 int count = 0; |
| 17 for (field in set) { |
| 18 count += field; |
| 19 } |
| 20 Expect.equals(3, count); |
| 21 |
| 22 count = 0; |
| 23 for (x in set) { |
| 24 count += x; |
| 25 } |
| 26 Expect.equals(3, count); |
| 27 } |
| 28 } |
| 29 |
| 30 void main() { |
| 31 new A().test(); |
| 32 } |
| OLD | NEW |