dart-sdk/tests/standalone_2/string_overflow_test.dart
Martin Kustermann 706965fd2c [gardening] Fix string_overflow_test.dart
The test was originally introduced in [0]. This restores its state to
how it was written back then with some small adjustements.

[0] d8ef2ae7 https://codereview.chromium.org//16783003

TEST=standalone{,_2}/string_overflow_test

Fixes https://github.com/dart-lang/sdk/issues/46225

Change-Id: I255f676481f2ab6e906ebfe4612d394c29663dd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202482
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-06-04 14:38:16 +00:00

27 lines
734 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.
// @dart = 2.9
// Test to ensure that the VM does not have an integer overflow issue
// when concatenating strings.
// See https://github.com/dart-lang/sdk/issues/11214
import "package:expect/expect.dart";
main() {
String a = "a";
var caughtOutOfMemoryException = false;
try {
while (true) {
a = "$a$a$a$a$a$a$a$a";
}
} on OutOfMemoryError {
caughtOutOfMemoryException = true;
}
Expect.isTrue(caughtOutOfMemoryException);
Expect.isTrue(a.startsWith('aaaaa') && a.length > 1024);
}