Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: test/version_test.dart

Issue 1127783002: Add more set-like version constraint operations. (Closed) Base URL: git@github.com:dart-lang/pub_semver@master
Patch Set: Code review changes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/version_test.dart
diff --git a/test/version_test.dart b/test/version_test.dart
index 8745006058e25f387a4c338df2695051134dbae3..e3d1b49a9d6092e73aed4076d556c516c01e8bdb 100644
--- a/test/version_test.dart
+++ b/test/version_test.dart
@@ -138,6 +138,22 @@ main() {
new Version.parse('1.2.3+build')));
});
+ test('allowsAll()', () {
+ expect(v123.allowsAll(v123), isTrue);
+ expect(v123.allowsAll(v003), isFalse);
+ expect(v123.allowsAll(new VersionRange(min: v114, max: v124)), isFalse);
+ expect(v123.allowsAll(VersionConstraint.any), isFalse);
+ expect(v123.allowsAll(VersionConstraint.empty), isTrue);
+ });
+
+ test('allowsAny()', () {
+ expect(v123.allowsAny(v123), isTrue);
+ expect(v123.allowsAny(v003), isFalse);
+ expect(v123.allowsAny(new VersionRange(min: v114, max: v124)), isTrue);
+ expect(v123.allowsAny(VersionConstraint.any), isTrue);
+ expect(v123.allowsAny(VersionConstraint.empty), isFalse);
+ });
+
test('intersect()', () {
// Intersecting the same version returns the version.
expect(v123.intersect(v123), equals(v123));
@@ -154,6 +170,40 @@ main() {
isTrue);
});
+ group('union()', () {
+ test("with the same version returns the version", () {
+ expect(v123.union(v123), equals(v123));
+ });
+
+ test("with a different version returns a version that matches both", () {
+ var result = v123.union(v080);
+ expect(result, allows(v123));
+ expect(result, allows(v080));
+
+ // Nothing in between should match.
+ expect(result, doesNotAllow(v114));
+ });
+
+ test("with a range returns the range if it contains the version", () {
+ var range = new VersionRange(min: v114, max: v124);
+ expect(v123.union(range), equals(range));
+ });
+
+ test("with a range with the version on the edge, expands the range", () {
+ expect(v124.union(new VersionRange(min: v114, max: v124)),
+ equals(new VersionRange(min: v114, max: v124, includeMax: true)));
+ expect(v114.union(new VersionRange(min: v114, max: v124)),
+ equals(new VersionRange(min: v114, max: v124, includeMin: true)));
+ });
+
+ test("with a range allows both the range and the version if the range "
+ "doesn't contain the version", () {
+ var result = v123.union(new VersionRange(min: v003, max: v114));
+ expect(result, allows(v123));
+ expect(result, allows(v010));
+ });
+ });
+
test('isEmpty', () {
expect(v123.isEmpty, isFalse);
});

Powered by Google App Engine
This is Rietveld 408576698