| 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('version_test'); | 5 #library('version_test'); |
| 6 | 6 |
| 7 #import('../../../lib/unittest/unittest.dart'); | 7 #import('../../../lib/unittest/unittest.dart'); |
| 8 #import('../../pub/utils.dart'); | 8 #import('../../pub/utils.dart'); |
| 9 #import('../../pub/version.dart'); | 9 #import('../../pub/version.dart'); |
| 10 | 10 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 }); | 377 }); |
| 378 }); | 378 }); |
| 379 } | 379 } |
| 380 | 380 |
| 381 class VersionConstraintMatcher implements Matcher { | 381 class VersionConstraintMatcher implements Matcher { |
| 382 final List<Version> _expected; | 382 final List<Version> _expected; |
| 383 final bool _allow; | 383 final bool _allow; |
| 384 | 384 |
| 385 VersionConstraintMatcher(this._expected, this._allow); | 385 VersionConstraintMatcher(this._expected, this._allow); |
| 386 | 386 |
| 387 bool matches(item) => (item is VersionConstraint) && | 387 bool matches(item, MatchState matchState) => (item is VersionConstraint) && |
| 388 _expected.every((version) => item.allows(version) == _allow); | 388 _expected.every((version) => item.allows(version) == _allow); |
| 389 | 389 |
| 390 Description describe(Description description) => | 390 Description describe(Description description) => |
| 391 description.add(' ${_allow ? "allows" : "does not allow"} versions'); | 391 description.add(' ${_allow ? "allows" : "does not allow"} versions'); |
| 392 | 392 |
| 393 Description describeMismatch(item, Description mismatchDescription) { | 393 Description describeMismatch(item, Description mismatchDescription, |
| 394 MatchState matchState, bool verbose) { |
| 394 if (item is! VersionConstraint) { | 395 if (item is! VersionConstraint) { |
| 395 mismatchDescription.add('was not a VersionConstraint'); | 396 mismatchDescription.add('was not a VersionConstraint'); |
| 396 return mismatchDescription; | 397 return mismatchDescription; |
| 397 } | 398 } |
| 398 | 399 |
| 399 bool first = true; | 400 bool first = true; |
| 400 for (var version in _expected) { | 401 for (var version in _expected) { |
| 401 if (item.allows(version) != _allow) { | 402 if (item.allows(version) != _allow) { |
| 402 if (first) { | 403 if (first) { |
| 403 if (_allow) { | 404 if (_allow) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 424 Matcher doesNotAllow(List<Version> versions) => | 425 Matcher doesNotAllow(List<Version> versions) => |
| 425 new VersionConstraintMatcher(versions, false); | 426 new VersionConstraintMatcher(versions, false); |
| 426 | 427 |
| 427 throwsIllegalArg(function) { | 428 throwsIllegalArg(function) { |
| 428 expectThrow(function, (e) => e is IllegalArgumentException); | 429 expectThrow(function, (e) => e is IllegalArgumentException); |
| 429 } | 430 } |
| 430 | 431 |
| 431 throwsBadFormat(function) { | 432 throwsBadFormat(function) { |
| 432 expectThrow(function, (e) => e is FormatException); | 433 expectThrow(function, (e) => e is FormatException); |
| 433 } | 434 } |
| OLD | NEW |