diff --git a/source/dub/test/base.d b/source/dub/test/base.d index b9407c7..af26c58 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -478,7 +478,7 @@ public class MockPackageSupplier : PackageSupplier { /// Mapping of package name to packages, ordered by `Version` - protected Package[][PackageName] pkgs; + protected Package[Version][PackageName] pkgs; /// URL this was instantiated with protected string url; @@ -499,7 +499,7 @@ public override Version[] getVersions(in PackageName name) { if (auto ppkgs = name.main in this.pkgs) - return (*ppkgs).map!(pkg => pkg.version_).array; + return (*ppkgs).keys; return null; } @@ -517,12 +517,14 @@ { import dub.recipe.json; + Package match; if (auto ppkgs = name.main in this.pkgs) - foreach_reverse (pkg; *ppkgs) - if ((!pkg.version_.isPreRelease || pre_release) && - dep.matches(pkg.version_)) - return toJson(pkg.recipe); - return Json.init; + foreach (vers, pkg; *ppkgs) + if ((!vers.isPreRelease || pre_release) && + dep.matches(vers) && + (match is null || match.version_ < vers)) + match = pkg; + return match is null ? Json.init : toJson(match.recipe); } ///