blob: 44eaadc47a18d495ddca74a46e08494aad3c21c5 [file] [log] [blame]
// Copyright (c) 2018, 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.
// @dart = 2.9
/// @assertion Each iteration of the loop binds a new fresh variable
///
/// @description Checks that each iteration of the loop binds a new fresh
/// variable
/// @author sgrekhov@unipro.ru
import "../../Utils/expect.dart";
main() {
var closures = [
for (var i = 1; i < 4; i++) () => i++
];
int count = 1;
for (var closure in closures) {
Expect.equals(count++, closure());
}
count = 2;
for (var closure in closures) {
Expect.equals(count++, closure());
}
}