Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: tests/corelib/string_from_list_test.dart

Issue 11415130: Dart2js: Fix stack overflow in new String.fromCharCodes bug=6919 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/corelib/string_from_list_test.dart
diff --git a/tests/corelib/string_from_list_test.dart b/tests/corelib/string_from_list_test.dart
index ec435921ece5c07616432cc26016447558d7de02..23c90f251d99554ce4097a94c766ba55218ca89e 100644
--- a/tests/corelib/string_from_list_test.dart
+++ b/tests/corelib/string_from_list_test.dart
@@ -19,6 +19,26 @@ class StringFromListTest {
a.add(66);
Expect.equals("AB", new String.fromCharCodes(a));
}
+
+ // Long list (bug 6919).
+ for (int len in [499, 500, 501, 999, 100000]) {
+ List<int> list = new List(len);
+ for (int i = 0; i < len; i++) {
+ list[i] = 65 + (i % 26);
+ }
+ for (int i = len - 9; i < len; i++) {
+ list[i] = 48 + (len - i);
+ }
+ // We should not throw a stack overflow here.
+ String long = new String.fromCharCodes(list);
+ // Minimal sanity checking on the string.
+ Expect.isTrue(long.startsWith('ABCDE'));
+ Expect.isTrue(long.endsWith('987654321'));
+ int middle = len ~/ 2;
+ middle -= middle % 26;
+ Expect.equals('XYZABC', long.substring(middle - 3, middle + 3));
+ Expect.equals(len, long.length);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698