| 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 test_utils; | 5 library test_utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 return _matcher.matches(parsed, matchState); | 132 return _matcher.matches(parsed, matchState); |
| 133 } | 133 } |
| 134 | 134 |
| 135 Description describe(Description description) { | 135 Description describe(Description description) { |
| 136 return description.add('parses to a value that ') | 136 return description.add('parses to a value that ') |
| 137 .addDescriptionOf(_matcher); | 137 .addDescriptionOf(_matcher); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 // TODO(nweiz): remove this once it's built in to unittest (issue 7922). | |
| 142 /// A matcher for StateErrors. | |
| 143 const isStateError = const _StateError(); | |
| 144 | |
| 145 /// A matcher for functions that throw StateError. | |
| 146 const Matcher throwsStateError = | |
| 147 const Throws(isStateError); | |
| 148 | |
| 149 class _StateError extends TypeMatcher { | |
| 150 const _StateError() : super("StateError"); | |
| 151 bool matches(item, MatchState matchState) => item is StateError; | |
| 152 } | |
| 153 | |
| 154 /// A matcher for HttpExceptions. | 141 /// A matcher for HttpExceptions. |
| 155 const isHttpException = const _HttpException(); | 142 const isHttpException = const _HttpException(); |
| 156 | 143 |
| 157 /// A matcher for functions that throw HttpException. | 144 /// A matcher for functions that throw HttpException. |
| 158 const Matcher throwsHttpException = | 145 const Matcher throwsHttpException = |
| 159 const Throws(isHttpException); | 146 const Throws(isHttpException); |
| 160 | 147 |
| 161 class _HttpException extends TypeMatcher { | 148 class _HttpException extends TypeMatcher { |
| 162 const _HttpException() : super("HttpException"); | 149 const _HttpException() : super("HttpException"); |
| 163 bool matches(item, MatchState matchState) => item is HttpException; | 150 bool matches(item, MatchState matchState) => item is HttpException; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 183 const isSocketIOException = const _SocketIOException(); | 170 const isSocketIOException = const _SocketIOException(); |
| 184 | 171 |
| 185 /// A matcher for functions that throw SocketIOException. | 172 /// A matcher for functions that throw SocketIOException. |
| 186 const Matcher throwsSocketIOException = | 173 const Matcher throwsSocketIOException = |
| 187 const Throws(isSocketIOException); | 174 const Throws(isSocketIOException); |
| 188 | 175 |
| 189 class _SocketIOException extends TypeMatcher { | 176 class _SocketIOException extends TypeMatcher { |
| 190 const _SocketIOException() : super("SocketIOException"); | 177 const _SocketIOException() : super("SocketIOException"); |
| 191 bool matches(item, MatchState matchState) => item is SocketIOException; | 178 bool matches(item, MatchState matchState) => item is SocketIOException; |
| 192 } | 179 } |
| OLD | NEW |