mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:59:47 +00:00
d4154ac6dc
Change-Id: Iad2963c7f9c184b089dc6d15aa4442f58d194bc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151983 Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
28 lines
673 B
Dart
28 lines
673 B
Dart
// Copyright (c) 2013, 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Regression test for https://code.google.com/p/dart/issues/detail?id=7994.
|
|
|
|
void main() {
|
|
Expect.equals(-1, foo());
|
|
}
|
|
|
|
int foo() {
|
|
var list = List<int>.filled(1024, 0);
|
|
|
|
for (int i = 0; i < list.length; i++) list[i] = -i;
|
|
|
|
for (int n = list.length; n > 1; n--) {
|
|
for (int i = 0; i < n - 1; i++) {
|
|
if (list[i] > list[i + 1]) {
|
|
return list[i + 1];
|
|
}
|
|
}
|
|
}
|
|
|
|
throw "unreachable";
|
|
}
|