Index: pkg/http/test/io/utils.dart |
diff --git a/pkg/http/test/utils.dart b/pkg/http/test/io/utils.dart |
similarity index 73% |
copy from pkg/http/test/utils.dart |
copy to pkg/http/test/io/utils.dart |
index 051cbd4f0936d56265c336d4613b63981ee6c58e..53d112131f2dc3718987c188760ffc4c518ca607 100644 |
--- a/pkg/http/test/utils.dart |
+++ b/pkg/http/test/io/utils.dart |
@@ -1,8 +1,8 @@ |
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library test_utils; |
+library http.test.io_utils; |
import 'dart:async'; |
import 'dart:convert'; |
@@ -12,15 +12,14 @@ import 'package:http/http.dart'; |
import 'package:http/src/utils.dart'; |
import 'package:unittest/unittest.dart'; |
+export '../utils.dart'; |
+ |
/// The current server instance. |
HttpServer _server; |
/// The URL for the current server instance. |
Uri get serverUrl => Uri.parse('http://localhost:${_server.port}'); |
-/// A dummy URL for constructing requests that won't be sent. |
-Uri get dummyUrl => Uri.parse('http://dartlang.org/'); |
- |
/// Starts a new HTTP server. |
Future startServer() { |
return HttpServer.bind("localhost", 0).then((s) { |
@@ -119,61 +118,6 @@ void stopServer() { |
} |
} |
-/// Removes eight spaces of leading indentation from a multiline string. |
-/// |
-/// Note that this is very sensitive to how the literals are styled. They should |
-/// be: |
-/// ''' |
-/// Text starts on own line. Lines up with subsequent lines. |
-/// Lines are indented exactly 8 characters from the left margin. |
-/// Close is on the same line.''' |
-/// |
-/// This does nothing if text is only a single line. |
-// TODO(nweiz): Make this auto-detect the indentation level from the first |
-// non-whitespace line. |
-String cleanUpLiteral(String text) { |
- var lines = text.split('\n'); |
- if (lines.length <= 1) return text; |
- |
- for (var j = 0; j < lines.length; j++) { |
- if (lines[j].length > 8) { |
- lines[j] = lines[j].substring(8, lines[j].length); |
- } else { |
- lines[j] = ''; |
- } |
- } |
- |
- return lines.join('\n'); |
-} |
- |
-/// A matcher that matches JSON that parses to a value that matches the inner |
-/// matcher. |
-Matcher parse(matcher) => new _Parse(matcher); |
- |
-class _Parse extends Matcher { |
- final Matcher _matcher; |
- |
- _Parse(this._matcher); |
- |
- bool matches(item, Map matchState) { |
- if (item is! String) return false; |
- |
- var parsed; |
- try { |
- parsed = JSON.decode(item); |
- } catch (e) { |
- return false; |
- } |
- |
- return _matcher.matches(parsed, matchState); |
- } |
- |
- Description describe(Description description) { |
- return description.add('parses to a value that ') |
- .addDescriptionOf(_matcher); |
- } |
-} |
- |
/// A matcher for functions that throw HttpException. |
Matcher get throwsClientException => |
throwsA(new isInstanceOf<ClientException>()); |