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

Unified Diff: tests/corelib/iterable_join_test.dart

Issue 551823002: Optimize _GrowableArray._join and _StringBase._interpolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed operator+ change. Added more tests. Created 6 years, 3 months 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
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | tests/language/string_interpolate_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/iterable_join_test.dart
diff --git a/tests/corelib/iterable_join_test.dart b/tests/corelib/iterable_join_test.dart
index d2c750fbdf43fec677d312f148ba8745b478c031..133661715cb1a66e8cc06f3aba7442b0cfdc54a7 100644
--- a/tests/corelib/iterable_join_test.dart
+++ b/tests/corelib/iterable_join_test.dart
@@ -70,7 +70,73 @@ testCollections() {
testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ",");
}
+void testStringVariants() {
+ // ASCII
+ testJoin("axbxcxd", ["a", "b", "c", "d"], "x");
+ testJoin("a\u2000b\u2000c\u2000d", ["a", "b", "c", "d"], "\u2000");
+ testJoin("abcd", ["a", "b", "c", "d"], "");
+ testJoin("abcd", ["a", "b", "c", "d"]);
+ // Non-ASCII
+ testJoin("axbxcx\u2000", ["a", "b", "c", "\u2000"], "x");
+ testJoin("a\u2000b\u2000c\u2000\u2000", ["a", "b", "c", "\u2000"], "\u2000");
+ testJoin("abc\u2000", ["a", "b", "c", "\u2000"], "");
+ testJoin("abc\u2000", ["a", "b", "c", "\u2000"]);
+ // Long-ASCII
+ testJoin("ax" * 255 + "a", new List.generate(256, (_) => "a"), "x");
+ testJoin("a" * 256, new List.generate(256, (_) => "a"));
+ // Long-Non-ASCII
+ testJoin("a\u2000" * 255 + "a", new List.generate(256, (_) => "a"), "\u2000");
+ testJoin("\u2000" * 256, new List.generate(256, (_) => "\u2000"));
+ testJoin("\u2000x" * 255 + "\u2000",
+ new List.generate(256, (_) => "\u2000"), "x");
+
+ var o1 = new Stringable("x");
+ var o2 = new Stringable("\ufeff");
+ testJoin("xa" * 3 + "x", [o1, o1, o1, o1], "a");
+ testJoin("x" * 4, [o1, o1, o1, o1], "");
+ testJoin("x" * 4, [o1, o1, o1, o1]);
+
+ testJoin("\ufeffx" * 3 + "\ufeff", [o2, o2, o2, o2], "x");
+ testJoin("\ufeff" * 4, [o2, o2, o2, o2], "");
+ testJoin("\ufeff" * 4, [o2, o2, o2, o2]);
+
+ testJoin("a\u2000x\ufeff", ["a", "\u2000", o1, o2]);
+ testJoin("a\u2000\ufeffx", ["a", "\u2000", o2, o1]);
+ testJoin("ax\u2000\ufeff", ["a", o1, "\u2000", o2]);
+ testJoin("ax\ufeff\u2000", ["a", o1, o2, "\u2000"]);
+ testJoin("a\ufeffx\u2000", ["a", o2, o1, "\u2000"]);
+ testJoin("a\ufeff\u2000x", ["a", o2, "\u2000", o1]);
+
+ testJoin("\u2000ax\ufeff", ["\u2000", "a", o1, o2]);
+ testJoin("\u2000a\ufeffx", ["\u2000", "a", o2, o1]);
+ testJoin("xa\u2000\ufeff", [o1, "a", "\u2000", o2]);
+ testJoin("xa\ufeff\u2000", [o1, "a", o2, "\u2000"]);
+ testJoin("\ufeffax\u2000", [o2, "a", o1, "\u2000"]);
+ testJoin("\ufeffa\u2000x", [o2, "a", "\u2000", o1]);
+
+ testJoin("\u2000xa\ufeff", ["\u2000", o1, "a", o2]);
+ testJoin("\u2000\ufeffax", ["\u2000", o2, "a", o1]);
+ testJoin("x\u2000a\ufeff", [o1, "\u2000", "a", o2]);
+ testJoin("x\ufeffa\u2000", [o1, o2, "a", "\u2000"]);
+ testJoin("\ufeffxa\u2000", [o2, o1, "a", "\u2000"]);
+ testJoin("\ufeff\u2000ax", [o2, "\u2000", "a", o1]);
+
+ testJoin("\u2000x\ufeffa", ["\u2000", o1, o2, "a"]);
+ testJoin("\u2000\ufeffxa", ["\u2000", o2, o1, "a"]);
+ testJoin("x\u2000\ufeffa", [o1, "\u2000", o2, "a"]);
+ testJoin("x\ufeff\u2000a", [o1, o2, "\u2000", "a"]);
+ testJoin("\ufeffx\u2000a", [o2, o1, "\u2000", "a"]);
+ testJoin("\ufeff\u2000xa", [o2, "\u2000", o1, "a"]);
+}
+
+class Stringable {
+ final String value;
+ Stringable(this.value);
+ String toString() => value;
+}
+
main() {
testCollections();
+ testStringVariants();
// TODO(lrn): test scalar lists.
}
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | tests/language/string_interpolate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698