OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 curl_client_test; | 5 library curl_client_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 return _matcher.matches(parsed, matchState); | 162 return _matcher.matches(parsed, matchState); |
163 } | 163 } |
164 | 164 |
165 Description describe(Description description) { | 165 Description describe(Description description) { |
166 return description.add('parses to a value that ') | 166 return description.add('parses to a value that ') |
167 .addDescriptionOf(_matcher); | 167 .addDescriptionOf(_matcher); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 // TODO(nweiz): remove this once it's built in to unittest (issue 7922). | |
172 /// A matcher for StateErrors. | |
173 const isStateError = const _StateError(); | |
174 | |
175 /// A matcher for functions that throw StateError. | |
176 const Matcher throwsStateError = | |
177 const Throws(isStateError); | |
178 | |
179 class _StateError extends TypeMatcher { | |
180 const _StateError() : super("StateError"); | |
181 bool matches(item, MatchState matchState) => item is StateError; | |
182 } | |
183 | |
184 /// A matcher for HttpExceptions. | 171 /// A matcher for HttpExceptions. |
185 const isHttpException = const _HttpException(); | 172 const isHttpException = const _HttpException(); |
186 | 173 |
187 /// A matcher for functions that throw HttpException. | 174 /// A matcher for functions that throw HttpException. |
188 const Matcher throwsHttpException = | 175 const Matcher throwsHttpException = |
189 const Throws(isHttpException); | 176 const Throws(isHttpException); |
190 | 177 |
191 class _HttpException extends TypeMatcher { | 178 class _HttpException extends TypeMatcher { |
192 const _HttpException() : super("HttpException"); | 179 const _HttpException() : super("HttpException"); |
193 bool matches(item, MatchState matchState) => item is HttpException; | 180 bool matches(item, MatchState matchState) => item is HttpException; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 test('without following redirects', () { | 438 test('without following redirects', () { |
452 var request = new http.Request('GET', serverUrl.resolve('/redirect')); | 439 var request = new http.Request('GET', serverUrl.resolve('/redirect')); |
453 request.followRedirects = false; | 440 request.followRedirects = false; |
454 expect(new CurlClient().send(request).then(http.Response.fromStream) | 441 expect(new CurlClient().send(request).then(http.Response.fromStream) |
455 .then((response) { | 442 .then((response) { |
456 expect(response.statusCode, equals(302)); | 443 expect(response.statusCode, equals(302)); |
457 expect(response.isRedirect, true); | 444 expect(response.isRedirect, true); |
458 }), completes); | 445 }), completes); |
459 }); | 446 }); |
460 } | 447 } |
OLD | NEW |