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

Side by Side Diff: tests/corelib/string_buffer_test.dart

Issue 1086043002: dart2js implementation of StringBuffer.writeAll that optimizes better (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: use Duration instead of StringBuffer for pub tests... until we optimize that! Created 5 years, 8 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 | « sdk/lib/core/string_buffer.dart ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // TODO(srdjan): Move StringBuffer to visible names. 7 // TODO(srdjan): Move StringBuffer to visible names.
8 8
9 void testConstructor() { 9 void testConstructor() {
10 StringBuffer bf = new StringBuffer(""); 10 StringBuffer bf = new StringBuffer("");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void testWriteAll() { 89 void testWriteAll() {
90 StringBuffer bf = new StringBuffer(""); 90 StringBuffer bf = new StringBuffer("");
91 bf.writeAll(["foo", "bar", "a", "b", "c"]); 91 bf.writeAll(["foo", "bar", "a", "b", "c"]);
92 Expect.equals("foobarabc", bf.toString()); 92 Expect.equals("foobarabc", bf.toString());
93 93
94 bf.writeAll([]); 94 bf.writeAll([]);
95 Expect.equals("foobarabc", bf.toString()); 95 Expect.equals("foobarabc", bf.toString());
96 96
97 bf.writeAll(["", "", ""]); 97 bf.writeAll(["", "", ""]);
98 Expect.equals("foobarabc", bf.toString()); 98 Expect.equals("foobarabc", bf.toString());
99
100 bf.writeAll(["", "", ""], "");
101 Expect.equals("foobarabc", bf.toString());
102
103 StringBuffer bf2 = new StringBuffer("");
104 bf2.writeAll([], "s");
105 Expect.equals("", bf2.toString());
106
107 StringBuffer bf3 = new StringBuffer("");
108 bf3.writeAll(["a"], "s");
109 Expect.equals("a", bf3.toString());
110
111 StringBuffer bf4 = new StringBuffer("");
112 bf4.writeAll(["a", "b"], "s");
113 Expect.equals("asb", bf4.toString());
114 }
115
116 void testWriteAll2() {
117 // Passing `null` for separator is an error that is checked when the iterable
118 // is not empty. This is not specified in the documentation but we want
119 // implementations to be consistent.
120 StringBuffer bf1 = new StringBuffer("");
121 bf1.writeAll([], null);
122 Expect.equals("", bf1.toString());
123
124 StringBuffer bf2 = new StringBuffer("");
125 Expect.throws(() { bf2.writeAll([1], null); });
126 }
127
128 void testWriteln() {
129 StringBuffer bf1 = new StringBuffer("");
130 bf1.writeln("Hello");
131 Expect.equals("Hello\n", bf1.toString());
132
133 StringBuffer bf2 = new StringBuffer("");
134 bf2.writeln();
135 Expect.equals("\n", bf2.toString());
136
137 StringBuffer bf3 = new StringBuffer("");
138 bf3.writeln("\n");
139 bf3.writeln(null);
140 bf3.writeln(1);
141 Expect.equals("\n\nnull\n1\n", bf3.toString());
99 } 142 }
100 143
101 void testClear() { 144 void testClear() {
102 StringBuffer bf = new StringBuffer(""); 145 StringBuffer bf = new StringBuffer("");
103 bf.write("foo"); 146 bf.write("foo");
104 bf.clear(); 147 bf.clear();
105 Expect.equals("", bf.toString()); 148 Expect.equals("", bf.toString());
106 testBufferLength(0, bf); 149 testBufferLength(0, bf);
107 150
108 bf.write("bar"); 151 bf.write("bar");
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 222 }
180 223
181 void main() { 224 void main() {
182 testToString(); 225 testToString();
183 testConstructor(); 226 testConstructor();
184 testLength(); 227 testLength();
185 testIsEmpty(); 228 testIsEmpty();
186 testWrite(); 229 testWrite();
187 testWriteCharCode(); 230 testWriteCharCode();
188 testWriteAll(); 231 testWriteAll();
232 testWriteAll2();
233 testWriteln();
189 testClear(); 234 testClear();
190 testChaining(); 235 testChaining();
191 } 236 }
OLDNEW
« no previous file with comments | « sdk/lib/core/string_buffer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698