[vm/dart2js] Fix language/string/overflow_test.dart

Changes the test to concatenate strings indefinitely. This way the test
makes no assumptions about the amount of available memory, and the
concatenation result always stays alive.

Closes: https://github.com/dart-lang/sdk/issues/46055

Change-Id: I1a0da68b2ab5cfc00cfe834f0666f6f797a69ec4
Fixed: 46055
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200460
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Daco Harkes 2021-05-18 12:41:43 +00:00 committed by commit-bot@chromium.org
parent a0865fad28
commit 6ad3aaf57c
2 changed files with 8 additions and 4 deletions

View file

@ -9,13 +9,15 @@ import "package:expect/expect.dart";
main() {
String a = "a";
for (; a.length < 256 * 1024 * 1024;) a = a + a;
var exception_thrown = false;
try {
var concat = "$a$a$a$a$a$a$a$a";
while (true) {
a = "$a$a";
}
} on OutOfMemoryError catch (exc) {
exception_thrown = true;
}
Expect.isTrue(exception_thrown);
Expect.isTrue(a.startsWith('aaaaa') && a.length > 1024);
}

View file

@ -11,13 +11,15 @@ import "package:expect/expect.dart";
main() {
String a = "a";
for (; a.length < 256 * 1024 * 1024;) a = a + a;
var exception_thrown = false;
try {
var concat = "$a$a$a$a$a$a$a$a";
while (true) {
a = "$a$a";
}
} on OutOfMemoryError catch (exc) {
exception_thrown = true;
}
Expect.isTrue(exception_thrown);
Expect.isTrue(a.startsWith('aaaaa') && a.length > 1024);
}