Skip to content

Commit

Permalink
Deprecate Dependency.matchesAny in favor of VersionRange
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Aug 2, 2022
1 parent f358dbf commit ea2ebbc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions source/dub/dependency.d
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ struct Dependency {
This is true in particular for the `any` constant.
*/
deprecated("Use `VersionRange.matchesAny` directly")
bool matchesAny() const scope @safe {
return this.m_value.match!(
(Repository v) => true,
Expand All @@ -435,13 +436,6 @@ struct Dependency {
);
}

unittest {
assert(Dependency("*").matchesAny);
assert(!Dependency(">0.0.0").matchesAny);
assert(!Dependency(">=1.0.0").matchesAny);
assert(!Dependency("<1.0.0").matchesAny);
}

/** Tests if the specification matches a specific version.
*/
bool matches(string vers, VersionMatchMode mode = VersionMatchMode.standard) const @safe
Expand Down Expand Up @@ -962,6 +956,13 @@ private struct VersionRange
&& this.m_versB == Version.maxRelease;
}

unittest {
assert(VersionRange.fromString("*").matchesAny);
assert(!VersionRange.fromString(">0.0.0").matchesAny);
assert(!VersionRange.fromString(">=1.0.0").matchesAny);
assert(!VersionRange.fromString("<1.0.0").matchesAny);
}

public static VersionRange fromString (string ves) @safe
{
static import std.string;
Expand Down

0 comments on commit ea2ebbc

Please sign in to comment.