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

Side by Side Diff: dart/pkg/shelf/test/message_test.dart

Issue 342323004: Throw a StateError if read()/readAsString() is called multiple times (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « dart/pkg/shelf/lib/src/message.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library shelf.message_test; 5 library shelf.message_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:shelf/src/message.dart'; 10 import 'package:shelf/src/message.dart';
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 WORLD_BYTES 124 WORLD_BYTES
125 ]))); 125 ])));
126 126
127 controller.add(HELLO_BYTES); 127 controller.add(HELLO_BYTES);
128 return new Future(() { 128 return new Future(() {
129 controller 129 controller
130 ..add(WORLD_BYTES) 130 ..add(WORLD_BYTES)
131 ..close(); 131 ..close();
132 }); 132 });
133 }); 133 });
134
135 test("throws when calling read()/readAsString() multiple times", () {
136 var request;
137
138 request = _createMessage();
139 expect(request.read().toList(), completion(isEmpty));
140 expect(() => request.read(), throwsStateError);
141
142 request = _createMessage();
143 expect(request.readAsString(), completion(isEmpty));
144 expect(() => request.readAsString(), throwsStateError);
145
146 request = _createMessage();
147 expect(request.readAsString(), completion(isEmpty));
148 expect(() => request.read(), throwsStateError);
149
150 request = _createMessage();
151 expect(request.read().toList(), completion(isEmpty));
152 expect(() => request.readAsString(), throwsStateError);
153 });
134 }); 154 });
135 155
136 group("contentLength", () { 156 group("contentLength", () {
137 test("is null without a content-length header", () { 157 test("is null without a content-length header", () {
138 var request = _createMessage(); 158 var request = _createMessage();
139 expect(request.contentLength, isNull); 159 expect(request.contentLength, isNull);
140 }); 160 });
141 161
142 test("comes from the content-length header", () { 162 test("comes from the content-length header", () {
143 var request = _createMessage(headers: { 163 var request = _createMessage(headers: {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 }).encoding, isNull); 202 }).encoding, isNull);
183 }); 203 });
184 204
185 test("comes from the content-type charset parameter", () { 205 test("comes from the content-type charset parameter", () {
186 expect(_createMessage(headers: { 206 expect(_createMessage(headers: {
187 'content-type': 'text/plain; charset=iso-8859-1' 207 'content-type': 'text/plain; charset=iso-8859-1'
188 }).encoding, equals(LATIN1)); 208 }).encoding, equals(LATIN1));
189 }); 209 });
190 }); 210 });
191 } 211 }
OLDNEW
« no previous file with comments | « dart/pkg/shelf/lib/src/message.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698