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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | tests/language/string_interpolate_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class IC { 7 class IC {
8 int count = 0; 8 int count = 0;
9 String toString() => "${count++}"; 9 String toString() => "${count++}";
10 } 10 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 testArray(const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); 63 testArray(const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
64 64
65 testJoin("a,b,c,d", ["a", "b", "c", "d"].map((x) => x), ","); 65 testJoin("a,b,c,d", ["a", "b", "c", "d"].map((x) => x), ",");
66 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x), ""); 66 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x), "");
67 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x)); 67 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x));
68 testJoin("null,b,c,d", [null,"b","c","d"].map((x) => x), ","); 68 testJoin("null,b,c,d", [null,"b","c","d"].map((x) => x), ",");
69 testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ","); 69 testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ",");
70 testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ","); 70 testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ",");
71 } 71 }
72 72
73 void testStringVariants() {
74 // ASCII
75 testJoin("axbxcxd", ["a", "b", "c", "d"], "x");
76 testJoin("a\u2000b\u2000c\u2000d", ["a", "b", "c", "d"], "\u2000");
77 testJoin("abcd", ["a", "b", "c", "d"], "");
78 testJoin("abcd", ["a", "b", "c", "d"]);
79 // Non-ASCII
80 testJoin("axbxcx\u2000", ["a", "b", "c", "\u2000"], "x");
81 testJoin("a\u2000b\u2000c\u2000\u2000", ["a", "b", "c", "\u2000"], "\u2000");
82 testJoin("abc\u2000", ["a", "b", "c", "\u2000"], "");
83 testJoin("abc\u2000", ["a", "b", "c", "\u2000"]);
84 // Long-ASCII
85 testJoin("ax" * 255 + "a", new List.generate(256, (_) => "a"), "x");
86 testJoin("a" * 256, new List.generate(256, (_) => "a"));
87 // Long-Non-ASCII
88 testJoin("a\u2000" * 255 + "a", new List.generate(256, (_) => "a"), "\u2000");
89 testJoin("\u2000" * 256, new List.generate(256, (_) => "\u2000"));
90 testJoin("\u2000x" * 255 + "\u2000",
91 new List.generate(256, (_) => "\u2000"), "x");
92
93 var o1 = new Stringable("x");
94 var o2 = new Stringable("\ufeff");
95 testJoin("xa" * 3 + "x", [o1, o1, o1, o1], "a");
96 testJoin("x" * 4, [o1, o1, o1, o1], "");
97 testJoin("x" * 4, [o1, o1, o1, o1]);
98
99 testJoin("\ufeffx" * 3 + "\ufeff", [o2, o2, o2, o2], "x");
100 testJoin("\ufeff" * 4, [o2, o2, o2, o2], "");
101 testJoin("\ufeff" * 4, [o2, o2, o2, o2]);
102
103 testJoin("a\u2000x\ufeff", ["a", "\u2000", o1, o2]);
104 testJoin("a\u2000\ufeffx", ["a", "\u2000", o2, o1]);
105 testJoin("ax\u2000\ufeff", ["a", o1, "\u2000", o2]);
106 testJoin("ax\ufeff\u2000", ["a", o1, o2, "\u2000"]);
107 testJoin("a\ufeffx\u2000", ["a", o2, o1, "\u2000"]);
108 testJoin("a\ufeff\u2000x", ["a", o2, "\u2000", o1]);
109
110 testJoin("\u2000ax\ufeff", ["\u2000", "a", o1, o2]);
111 testJoin("\u2000a\ufeffx", ["\u2000", "a", o2, o1]);
112 testJoin("xa\u2000\ufeff", [o1, "a", "\u2000", o2]);
113 testJoin("xa\ufeff\u2000", [o1, "a", o2, "\u2000"]);
114 testJoin("\ufeffax\u2000", [o2, "a", o1, "\u2000"]);
115 testJoin("\ufeffa\u2000x", [o2, "a", "\u2000", o1]);
116
117 testJoin("\u2000xa\ufeff", ["\u2000", o1, "a", o2]);
118 testJoin("\u2000\ufeffax", ["\u2000", o2, "a", o1]);
119 testJoin("x\u2000a\ufeff", [o1, "\u2000", "a", o2]);
120 testJoin("x\ufeffa\u2000", [o1, o2, "a", "\u2000"]);
121 testJoin("\ufeffxa\u2000", [o2, o1, "a", "\u2000"]);
122 testJoin("\ufeff\u2000ax", [o2, "\u2000", "a", o1]);
123
124 testJoin("\u2000x\ufeffa", ["\u2000", o1, o2, "a"]);
125 testJoin("\u2000\ufeffxa", ["\u2000", o2, o1, "a"]);
126 testJoin("x\u2000\ufeffa", [o1, "\u2000", o2, "a"]);
127 testJoin("x\ufeff\u2000a", [o1, o2, "\u2000", "a"]);
128 testJoin("\ufeffx\u2000a", [o2, o1, "\u2000", "a"]);
129 testJoin("\ufeff\u2000xa", [o2, "\u2000", o1, "a"]);
130 }
131
132 class Stringable {
133 final String value;
134 Stringable(this.value);
135 String toString() => value;
136 }
137
73 main() { 138 main() {
74 testCollections(); 139 testCollections();
140 testStringVariants();
75 // TODO(lrn): test scalar lists. 141 // TODO(lrn): test scalar lists.
76 } 142 }
OLDNEW
« 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