| OLD | NEW |
| 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 mocks; | 5 library mocks; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 @MirrorsUsed(targets: 'mocks', override: '*') | 10 @MirrorsUsed(targets: 'mocks', override: '*') |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 @override | 239 @override |
| 240 Description describe(Description description) { | 240 Description describe(Description description) { |
| 241 return description.addDescriptionOf( | 241 return description.addDescriptionOf( |
| 242 'response with identifier "$_id" and without error'); | 242 'response with identifier "$_id" and without error'); |
| 243 } | 243 } |
| 244 | 244 |
| 245 @override | 245 @override |
| 246 bool matches(item, Map matchState) { | 246 bool matches(item, Map matchState) { |
| 247 Response response = item; | 247 Response response = item; |
| 248 return response.id == _id && response.error == null; | 248 return response != null && response.id == _id && response.error == null; |
| 249 } | 249 } |
| 250 | 250 |
| 251 @override | 251 @override |
| 252 Description describeMismatch(item, Description mismatchDescription, | 252 Description describeMismatch(item, Description mismatchDescription, |
| 253 Map matchState, bool verbose) { | 253 Map matchState, bool verbose) { |
| 254 Response response = item; | 254 Response response = item; |
| 255 var id = response.id; | 255 if (response == null) { |
| 256 RequestError error = response.error; | 256 mismatchDescription.add('is null response'); |
| 257 mismatchDescription.add('has identifier "$id"'); | 257 } else { |
| 258 if (error != null) { | 258 var id = response.id; |
| 259 mismatchDescription.add(' and has error $error'); | 259 RequestError error = response.error; |
| 260 mismatchDescription.add('has identifier "$id"'); |
| 261 if (error != null) { |
| 262 mismatchDescription.add(' and has error $error'); |
| 263 } |
| 260 } | 264 } |
| 261 return mismatchDescription; | 265 return mismatchDescription; |
| 262 } | 266 } |
| 263 } | 267 } |
| 264 | 268 |
| 265 | 269 |
| 266 /** | 270 /** |
| 267 * A [Matcher] that check that the given [Response] has an expected identifier | 271 * A [Matcher] that check that the given [Response] has an expected identifier |
| 268 * and has an error. | 272 * and has an error. |
| 269 */ | 273 */ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 /** | 320 /** |
| 317 * Dependency list that will be returned by the next call to [computePackageMa
p]. | 321 * Dependency list that will be returned by the next call to [computePackageMa
p]. |
| 318 */ | 322 */ |
| 319 Set<String> dependencies = new Set<String>(); | 323 Set<String> dependencies = new Set<String>(); |
| 320 | 324 |
| 321 @override | 325 @override |
| 322 PackageMapInfo computePackageMap(resource.Folder folder) { | 326 PackageMapInfo computePackageMap(resource.Folder folder) { |
| 323 return new PackageMapInfo(packageMap, dependencies); | 327 return new PackageMapInfo(packageMap, dependencies); |
| 324 } | 328 } |
| 325 } | 329 } |
| OLD | NEW |