Chromium Code Reviews| Index: pkg/kernel/testcases/closures/syncstar.dart |
| diff --git a/pkg/kernel/testcases/closures/syncstar.dart b/pkg/kernel/testcases/closures/syncstar.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4c3c9ac6655ab33b1ea235dec5ddc5821b038530 |
| --- /dev/null |
| +++ b/pkg/kernel/testcases/closures/syncstar.dart |
| @@ -0,0 +1,21 @@ |
| +/* |
|
Dmitry Stefantsov
2017/08/24 11:49:57
Please, use one-line comments and add a descriptio
sjindel
2017/08/24 14:50:14
Done.
sjindel
2017/08/24 14:50:14
Done.
Dmitry Stefantsov
2017/08/24 15:07:29
Nope :)
sjindel
2017/08/24 15:13:42
Oops!
|
| + * Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| + * for details. All rights reserved. Use of this source code is governed by a |
| + * BSD-style license that can be found in the LICENSE file. |
| + */ |
| +range(int high) { |
| + iter(int low) sync* { |
| + while (high-- > low) yield high; |
| + } |
| + |
| + return iter; |
| +} |
| + |
| +main() { |
| + var sum = 0; |
| + for (var x in range(10)(2)) sum += x; |
| + |
| + if (sum != 44) { |
| + throw new Exception("Incorrect output."); |
| + } |
| +} |