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

Side by Side Diff: tests/standalone/src/StringStreamTest.dart

Issue 8477026: Change the handling of the close event in the StringInputStream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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/bin/string_stream.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 class ListInputStream implements InputStream { 5 class ListInputStream implements InputStream {
6 List<int> read() { 6 List<int> read() {
7 var result = _data; 7 var result = _data;
8 _data = null; 8 _data = null;
9 return result; 9 return result;
10 } 10 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 s.close(); 114 s.close();
115 } else if (stage == 1) { 115 } else if (stage == 1) {
116 line = stream.readLine(); 116 line = stream.readLine();
117 Expect.equals("Line", line); 117 Expect.equals("Line", line);
118 line = stream.readLine(); 118 line = stream.readLine();
119 Expect.equals(null, line); 119 Expect.equals(null, line);
120 Expect.equals(true, stream.closed); 120 Expect.equals(true, stream.closed);
121 stage++; 121 stage++;
122 } 122 }
123 } 123 }
124
125 void streamClosed() {
126 Expect.equals(2, stage);
127 }
128
124 stream.dataHandler = stringData; 129 stream.dataHandler = stringData;
130 stream.closeHandler = streamClosed;
125 s.write("Line".charCodes()); 131 s.write("Line".charCodes());
126 Expect.equals(2, stage); 132 Expect.equals(2, stage);
127 } 133 }
128 134
129 void testReadLine2() { 135 void testReadLine2() {
130 InputStream s = new ListInputStream(); 136 InputStream s = new ListInputStream();
131 StringInputStream stream = new StringInputStream(s); 137 StringInputStream stream = new StringInputStream(s);
132 var stage = 0; 138 var stage = 0;
133 139
134 void stringData() { 140 void stringData() {
(...skipping 30 matching lines...) Expand all
165 } else if (stage == 3) { 171 } else if (stage == 3) {
166 // The final \r can now be interpreted as an end of line. 172 // The final \r can now be interpreted as an end of line.
167 line = stream.readLine(); 173 line = stream.readLine();
168 Expect.equals("", line); 174 Expect.equals("", line);
169 line = stream.readLine(); 175 line = stream.readLine();
170 Expect.equals(null, line); 176 Expect.equals(null, line);
171 Expect.equals(true, stream.closed); 177 Expect.equals(true, stream.closed);
172 stage++; 178 stage++;
173 } 179 }
174 } 180 }
181
182 void streamClosed() {
183 Expect.equals(4, stage);
184 }
185
175 stream.dataHandler = stringData; 186 stream.dataHandler = stringData;
187 stream.closeHandler = streamClosed;
176 s.write("Line1\nLine2\r\nLine3\rLi".charCodes()); 188 s.write("Line1\nLine2\r\nLine3\rLi".charCodes());
177 Expect.equals(4, stage); 189 Expect.equals(4, stage);
178 } 190 }
179 191
180 main() { 192 main() {
181 testUtf8(); 193 testUtf8();
182 testLatin1(); 194 testLatin1();
183 testAscii(); 195 testAscii();
184 testReadLine1(); 196 testReadLine1();
185 testReadLine2(); 197 testReadLine2();
186 } 198 }
OLDNEW
« no previous file with comments | « runtime/bin/string_stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698