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"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 foo(a, index) { | 7 foo(a, index) { |
8 if (a.length < index) { | 8 if (a.length < index) { |
9 for (int i = a.length; i <= index; i++) a.add(i); | 9 for (int i = a.length; i <= index; i++) a.add(i); |
10 } | 10 } |
11 // dart2js was reusing the a.length from above. | 11 // dart2js was reusing the a.length from above. |
12 return a[a.length - 1]; | 12 return a[a.length - 1]; |
13 } | 13 } |
14 | 14 |
15 void main() { | 15 void main() { |
16 Expect.equals(3, foo([0], 3)); | 16 Expect.equals(3, foo([0], 3)); |
17 } | 17 } |
OLD | NEW |