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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/string_buffer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_buffer_test.dart
diff --git a/tests/corelib/string_buffer_test.dart b/tests/corelib/string_buffer_test.dart
index 2c556f79109515b4842e543158575ec7a816db3e..8a24b35a306d702236de56df9f7a21e103bc1e26 100644
--- a/tests/corelib/string_buffer_test.dart
+++ b/tests/corelib/string_buffer_test.dart
@@ -96,6 +96,49 @@ void testWriteAll() {
bf.writeAll(["", "", ""]);
Expect.equals("foobarabc", bf.toString());
+
+ bf.writeAll(["", "", ""], "");
+ Expect.equals("foobarabc", bf.toString());
+
+ StringBuffer bf2 = new StringBuffer("");
+ bf2.writeAll([], "s");
+ Expect.equals("", bf2.toString());
+
+ StringBuffer bf3 = new StringBuffer("");
+ bf3.writeAll(["a"], "s");
+ Expect.equals("a", bf3.toString());
+
+ StringBuffer bf4 = new StringBuffer("");
+ bf4.writeAll(["a", "b"], "s");
+ Expect.equals("asb", bf4.toString());
+}
+
+void testWriteAll2() {
+ // Passing `null` for separator is an error that is checked when the iterable
+ // is not empty. This is not specified in the documentation but we want
+ // implementations to be consistent.
+ StringBuffer bf1 = new StringBuffer("");
+ bf1.writeAll([], null);
+ Expect.equals("", bf1.toString());
+
+ StringBuffer bf2 = new StringBuffer("");
+ Expect.throws(() { bf2.writeAll([1], null); });
+}
+
+void testWriteln() {
+ StringBuffer bf1 = new StringBuffer("");
+ bf1.writeln("Hello");
+ Expect.equals("Hello\n", bf1.toString());
+
+ StringBuffer bf2 = new StringBuffer("");
+ bf2.writeln();
+ Expect.equals("\n", bf2.toString());
+
+ StringBuffer bf3 = new StringBuffer("");
+ bf3.writeln("\n");
+ bf3.writeln(null);
+ bf3.writeln(1);
+ Expect.equals("\n\nnull\n1\n", bf3.toString());
}
void testClear() {
@@ -186,6 +229,8 @@ void main() {
testWrite();
testWriteCharCode();
testWriteAll();
+ testWriteAll2();
+ testWriteln();
testClear();
testChaining();
}
« 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