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

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

Issue 11645019: Fixed Issue 7508: Many StringBuffer methods return StringBuffer, but should be void. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « tests/co19/co19-runtime.status ('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 // TODO(srdjan): Move StringBuffer to visible names. 5 // TODO(srdjan): Move StringBuffer to visible names.
6 6
7 class StringBufferTest { 7 class StringBufferTest {
8 static testConstructor() { 8 static testConstructor() {
9 StringBuffer bf = new StringBuffer(""); 9 StringBuffer bf = new StringBuffer("");
10 Expect.equals(true, bf.isEmpty); 10 Expect.equals(true, bf.isEmpty);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Expect.equals("abcdefghijklmnopqrstuvwxyz\n" 56 Expect.equals("abcdefghijklmnopqrstuvwxyz\n"
57 "thequickbrownfoxjumpsoverthelazydog", 57 "thequickbrownfoxjumpsoverthelazydog",
58 bf.toString()); 58 bf.toString());
59 59
60 bf = new StringBuffer(""); 60 bf = new StringBuffer("");
61 for (int i = 0; i < 100000; i++) { 61 for (int i = 0; i < 100000; i++) {
62 bf.add(''); 62 bf.add('');
63 bf.add(""); 63 bf.add("");
64 } 64 }
65 Expect.equals("", bf.toString()); 65 Expect.equals("", bf.toString());
66
67 Expect.equals(bf, bf.add("foo"));
68 } 66 }
69 67
70 static testLength() { 68 static testLength() {
71 StringBuffer bf = new StringBuffer(""); 69 StringBuffer bf = new StringBuffer("");
72 Expect.equals(0, bf.length); 70 Expect.equals(0, bf.length);
73 bf.add("foo"); 71 bf.add("foo");
74 Expect.equals(3, bf.length); 72 Expect.equals(3, bf.length);
75 bf.add("bar"); 73 bf.add("bar");
76 Expect.equals(6, bf.length); 74 Expect.equals(6, bf.length);
77 bf.add(""); 75 bf.add("");
(...skipping 10 matching lines...) Expand all
88 static testAddAll() { 86 static testAddAll() {
89 StringBuffer bf = new StringBuffer(""); 87 StringBuffer bf = new StringBuffer("");
90 bf.addAll(["foo", "bar", "a", "b", "c"]); 88 bf.addAll(["foo", "bar", "a", "b", "c"]);
91 Expect.equals("foobarabc", bf.toString()); 89 Expect.equals("foobarabc", bf.toString());
92 90
93 bf.addAll([]); 91 bf.addAll([]);
94 Expect.equals("foobarabc", bf.toString()); 92 Expect.equals("foobarabc", bf.toString());
95 93
96 bf.addAll(["", "", ""]); 94 bf.addAll(["", "", ""]);
97 Expect.equals("foobarabc", bf.toString()); 95 Expect.equals("foobarabc", bf.toString());
98
99 Expect.equals(bf, bf.addAll(["foo"]));
100 } 96 }
101 97
102 static testClear() { 98 static testClear() {
103 StringBuffer bf = new StringBuffer(""); 99 StringBuffer bf = new StringBuffer("");
104 bf.add("foo"); 100 bf.add("foo");
105 bf.clear(); 101 bf.clear();
106 Expect.equals("", bf.toString()); 102 Expect.equals("", bf.toString());
107 Expect.equals(0, bf.length); 103 Expect.equals(0, bf.length);
108 104
109 bf.add("bar"); 105 bf.add("bar");
110 Expect.equals("bar", bf.toString()); 106 Expect.equals("bar", bf.toString());
111 Expect.equals(3, bf.length); 107 Expect.equals(3, bf.length);
112 bf.clear(); 108 bf.clear();
113 Expect.equals("", bf.toString()); 109 Expect.equals("", bf.toString());
114 Expect.equals(0, bf.length); 110 Expect.equals(0, bf.length);
115
116 Expect.equals(bf, bf.clear());
117 } 111 }
118 112
119 static testToString() { 113 static testToString() {
120 StringBuffer bf = new StringBuffer(""); 114 StringBuffer bf = new StringBuffer("");
121 Expect.equals("", bf.toString()); 115 Expect.equals("", bf.toString());
122 116
123 bf = new StringBuffer("foo"); 117 bf = new StringBuffer("foo");
124 Expect.equals("foo", bf.toString()); 118 Expect.equals("foo", bf.toString());
125 119
126 bf = new StringBuffer("foo"); 120 bf = new StringBuffer("foo");
127 bf.add("bar"); 121 bf.add("bar");
128 Expect.equals("foobar", bf.toString()); 122 Expect.equals("foobar", bf.toString());
129 } 123 }
130 124
131 static testChaining() { 125 static testChaining() {
132 StringBuffer bf = new StringBuffer(""); 126 StringBuffer bf = new StringBuffer("");
133 StringBuffer bf2 = new StringBuffer(""); 127 StringBuffer bf2 = new StringBuffer("");
134 bf2.add("bf2"); 128 bf2.add("bf2");
135 bf.add("foo") 129 bf..add("foo")
136 .add("bar") 130 ..add("bar")
137 .add(bf2) 131 ..add(bf2)
138 .add(bf2) 132 ..add(bf2)
139 .add("toto"); 133 ..add("toto");
140 Expect.equals("foobarbf2bf2toto", bf.toString()); 134 Expect.equals("foobarbf2bf2toto", bf.toString());
141 } 135 }
142 136
143 static testMain() { 137 static testMain() {
144 testToString(); 138 testToString();
145 testConstructor(); 139 testConstructor();
146 testLength(); 140 testLength();
147 testIsEmpty(); 141 testIsEmpty();
148 testAdd(); 142 testAdd();
149 testAddAll(); 143 testAddAll();
150 testClear(); 144 testClear();
151 testChaining(); 145 testChaining();
152 } 146 }
153 } 147 }
154 148
155 main() { 149 main() {
156 StringBufferTest.testMain(); 150 StringBufferTest.testMain();
157 } 151 }
OLDNEW
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698