| 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 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
| 6 | 6 |
| 7 import 'package:pub_semver/pub_semver.dart'; | 7 import 'package:pub_semver/pub_semver.dart'; |
| 8 | 8 |
| 9 import 'utils.dart'; | 9 import 'utils.dart'; |
| 10 | 10 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 }); | 195 }); |
| 196 | 196 |
| 197 test("with a range allows both the range and the version if the range " | 197 test("with a range allows both the range and the version if the range " |
| 198 "doesn't contain the version", () { | 198 "doesn't contain the version", () { |
| 199 var result = v123.union(new VersionRange(min: v003, max: v114)); | 199 var result = v123.union(new VersionRange(min: v003, max: v114)); |
| 200 expect(result, allows(v123)); | 200 expect(result, allows(v123)); |
| 201 expect(result, allows(v010)); | 201 expect(result, allows(v010)); |
| 202 }); | 202 }); |
| 203 }); | 203 }); |
| 204 | 204 |
| 205 group('difference()', () { |
| 206 test("with the same version returns an empty constraint", () { |
| 207 expect(v123.difference(v123), isEmpty); |
| 208 }); |
| 209 |
| 210 test("with a different version returns the original version", () { |
| 211 expect(v123.difference(v080), equals(v123)); |
| 212 }); |
| 213 |
| 214 test("returns an empty constraint with a range that contains the version", |
| 215 () { |
| 216 expect(v123.difference(new VersionRange(min: v114, max: v124)), isEmpty); |
| 217 }); |
| 218 |
| 219 test("returns the version constraint with a range that doesn't contain it", |
| 220 () { |
| 221 expect(v123.difference(new VersionRange(min: v140, max: v300)), |
| 222 equals(v123)); |
| 223 }); |
| 224 }); |
| 225 |
| 205 test('isEmpty', () { | 226 test('isEmpty', () { |
| 206 expect(v123.isEmpty, isFalse); | 227 expect(v123.isEmpty, isFalse); |
| 207 }); | 228 }); |
| 208 | 229 |
| 209 test('nextMajor', () { | 230 test('nextMajor', () { |
| 210 expect(v123.nextMajor, equals(v200)); | 231 expect(v123.nextMajor, equals(v200)); |
| 211 expect(v114.nextMajor, equals(v200)); | 232 expect(v114.nextMajor, equals(v200)); |
| 212 expect(v200.nextMajor, equals(v300)); | 233 expect(v200.nextMajor, equals(v300)); |
| 213 | 234 |
| 214 // Ignores pre-release if not on a major version. | 235 // Ignores pre-release if not on a major version. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 expect(new Version(1, 2, 3, pre: 'pre', build: 'bui').toString(), | 320 expect(new Version(1, 2, 3, pre: 'pre', build: 'bui').toString(), |
| 300 equals('1.2.3-pre+bui')); | 321 equals('1.2.3-pre+bui')); |
| 301 }); | 322 }); |
| 302 | 323 |
| 303 test('preserves leading zeroes', () { | 324 test('preserves leading zeroes', () { |
| 304 expect(new Version.parse('001.02.0003-01.dev+pre.002').toString(), | 325 expect(new Version.parse('001.02.0003-01.dev+pre.002').toString(), |
| 305 equals('001.02.0003-01.dev+pre.002')); | 326 equals('001.02.0003-01.dev+pre.002')); |
| 306 }); | 327 }); |
| 307 }); | 328 }); |
| 308 } | 329 } |
| OLD | NEW |