| 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 '../../../pkg/unittest/lib/unittest.dart'; | 7 import '../../../pkg/unittest/lib/unittest.dart'; |
| 8 import 'test_pub.dart'; |
| 8 import '../../pub/utils.dart'; | 9 import '../../pub/utils.dart'; |
| 9 import '../../pub/version.dart'; | 10 import '../../pub/version.dart'; |
| 10 | 11 |
| 11 main() { | 12 main() { |
| 12 final v123 = new Version.parse('1.2.3'); | 13 final v123 = new Version.parse('1.2.3'); |
| 13 final v114 = new Version.parse('1.1.4'); | 14 final v114 = new Version.parse('1.1.4'); |
| 14 final v124 = new Version.parse('1.2.4'); | 15 final v124 = new Version.parse('1.2.4'); |
| 15 final v200 = new Version.parse('2.0.0'); | 16 final v200 = new Version.parse('2.0.0'); |
| 16 final v234 = new Version.parse('2.3.4'); | 17 final v234 = new Version.parse('2.3.4'); |
| 17 final v250 = new Version.parse('2.5.0'); | 18 final v250 = new Version.parse('2.5.0'); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 }); | 296 }); |
| 296 }); | 297 }); |
| 297 | 298 |
| 298 test('isEmpty', () { | 299 test('isEmpty', () { |
| 299 expect(new VersionRange().isEmpty, isFalse); | 300 expect(new VersionRange().isEmpty, isFalse); |
| 300 expect(new VersionRange(min: v123, max: v124).isEmpty, isFalse); | 301 expect(new VersionRange(min: v123, max: v124).isEmpty, isFalse); |
| 301 }); | 302 }); |
| 302 }); | 303 }); |
| 303 | 304 |
| 304 group('VersionConstraint', () { | 305 group('VersionConstraint', () { |
| 306 test('any', () { |
| 307 expect(VersionConstraint.any.isAny, isTrue); |
| 308 expect(VersionConstraint.any, allows([ |
| 309 new Version.parse('0.0.0-blah'), |
| 310 new Version.parse('1.2.3'), |
| 311 new Version.parse('12345.678.90')])); |
| 312 }); |
| 313 |
| 305 test('empty', () { | 314 test('empty', () { |
| 306 expect(new VersionConstraint.empty().isEmpty, isTrue); | 315 expect(VersionConstraint.empty.isEmpty, isTrue); |
| 316 expect(VersionConstraint.empty, doesNotAllow([ |
| 317 new Version.parse('0.0.0-blah'), |
| 318 new Version.parse('1.2.3'), |
| 319 new Version.parse('12345.678.90')])); |
| 307 }); | 320 }); |
| 308 | 321 |
| 309 group('parse()', () { | 322 group('parse()', () { |
| 310 test('parses an exact version', () { | 323 test('parses an exact version', () { |
| 311 var constraint = new VersionConstraint.parse('1.2.3-alpha'); | 324 var constraint = new VersionConstraint.parse('1.2.3-alpha'); |
| 312 expect(constraint is Version, isTrue); | 325 expect(constraint is Version, isTrue); |
| 313 expect(constraint, equals(new Version(1, 2, 3, pre: 'alpha'))); | 326 expect(constraint, equals(new Version(1, 2, 3, pre: 'alpha'))); |
| 314 }); | 327 }); |
| 315 | 328 |
| 316 test('parses "any"', () { | 329 test('parses "any"', () { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 439 |
| 427 Matcher allows(List<Version> versions) => | 440 Matcher allows(List<Version> versions) => |
| 428 new VersionConstraintMatcher(versions, true); | 441 new VersionConstraintMatcher(versions, true); |
| 429 | 442 |
| 430 Matcher doesNotAllow(List<Version> versions) => | 443 Matcher doesNotAllow(List<Version> versions) => |
| 431 new VersionConstraintMatcher(versions, false); | 444 new VersionConstraintMatcher(versions, false); |
| 432 | 445 |
| 433 throwsIllegalArg(function) { | 446 throwsIllegalArg(function) { |
| 434 expect(function, throwsA((e) => e is ArgumentError)); | 447 expect(function, throwsA((e) => e is ArgumentError)); |
| 435 } | 448 } |
| OLD | NEW |