Skip to content

Commit

Permalink
newer beta versions have higher precedence - relates to #866
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 10, 2015
1 parent 1872390 commit 2f863c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions tests/Paket.Tests/FilterVersionSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ open FsUnit
let isInRangeNoPreRelease (versionRange:VersionRange) semVer =
VersionRequirement(versionRange,PreReleaseStatus.No).IsInRange (SemVer.Parse semVer)

let isInRangePreRelease (versionRange:VersionRange) semVer =
VersionRequirement(versionRange,PreReleaseStatus.All).IsInRange (SemVer.Parse semVer)

let isInRange (version:VersionRequirement) semVer =
version.IsInRange (SemVer.Parse semVer)

Expand All @@ -21,6 +24,7 @@ let ``can check if in range for Minimum``() =
"2.1" |> isInRangeNoPreRelease (VersionRange.Minimum (SemVer.Parse "2.2")) |> shouldEqual false
"2.2" |> isInRangeNoPreRelease (VersionRange.Minimum (SemVer.Parse "2.2")) |> shouldEqual true
"3.0" |> isInRangeNoPreRelease (VersionRange.Minimum (SemVer.Parse "2.2")) |> shouldEqual true
"1.1-beta" |> isInRangePreRelease (VersionRange.Minimum(SemVer.Parse "1.0-beta")) |> shouldEqual true

[<Test>]
let ``can check if in range for GreaterThan``() =
Expand Down
3 changes: 2 additions & 1 deletion tests/Paket.Tests/NugetVersionRangeParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ let ``can detect specific version``() =
[<Test>]
let ``can detect minimum version``() =
parseRange "2.2" |> shouldEqual (VersionRange.Minimum (SemVer.Parse "2.2"))
parseRange"1.2" |> shouldEqual (VersionRange.Minimum (SemVer.Parse "1.2"))
parseRange "1.2" |> shouldEqual (VersionRange.Minimum (SemVer.Parse "1.2"))
parseRange "1.0-beta" |> shouldEqual (VersionRange.Minimum(SemVer.Parse "1.0-beta"))

[<Test>]
let ``can detect greater than version``() =
Expand Down
15 changes: 8 additions & 7 deletions tests/Paket.Tests/NugetVersionRangeSerializerSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,41 @@ open NUnit.Framework
open FsUnit

[<Test>]
let ``can detect latest version``() =
let ``can format latest version``() =
VersionRequirement.Parse "" |> shouldEqual VersionRequirement.AllReleases

let format(versionRange:VersionRange) = versionRange.FormatInNuGetSyntax()

[<Test>]
let ``can detect specific version``() =
let ``can format specific version``() =
VersionRange.Specific(SemVer.Parse "2.2").FormatInNuGetSyntax() |> shouldEqual "[2.2]"
VersionRange.Specific(SemVer.Parse "1.2").FormatInNuGetSyntax() |> shouldEqual "[1.2]"

[<Test>]
let ``can detect minimum version``() =
let ``can format minimum version``() =
VersionRange.Minimum(SemVer.Parse "2.2").FormatInNuGetSyntax() |> shouldEqual "2.2"
VersionRange.Minimum(SemVer.Parse "1.2").FormatInNuGetSyntax() |> shouldEqual "1.2"
VersionRange.Minimum(SemVer.Parse "0").FormatInNuGetSyntax() |> shouldEqual ""
VersionRange.Minimum(SemVer.Parse "1.0-beta").FormatInNuGetSyntax() |> shouldEqual "1.0-beta"

[<Test>]
let ``can detect greater than version``() =
let ``can format greater than version``() =
VersionRange.GreaterThan(SemVer.Parse "2.2").FormatInNuGetSyntax() |> shouldEqual "(2.2,)"
VersionRange.GreaterThan(SemVer.Parse "1.2").FormatInNuGetSyntax() |> shouldEqual "(1.2,)"

[<Test>]
let ``can detect maximum version``() =
let ``can format maximum version``() =
VersionRange.Maximum(SemVer.Parse "2.2").FormatInNuGetSyntax() |> shouldEqual "(,2.2]"
VersionRange.Maximum(SemVer.Parse "0").FormatInNuGetSyntax() |> shouldEqual "(,0]"
VersionRange.Maximum(SemVer.Parse "1.2").FormatInNuGetSyntax() |> shouldEqual "(,1.2]"

[<Test>]
let ``can detect less than version``() =
let ``can format less than version``() =
VersionRange.LessThan(SemVer.Parse "2.2").FormatInNuGetSyntax() |> shouldEqual "(,2.2)"
VersionRange.LessThan(SemVer.Parse "1.2").FormatInNuGetSyntax() |> shouldEqual "(,1.2)"

[<Test>]
let ``can detect range version``() =
let ``can format range version``() =
VersionRange.Range(VersionRangeBound.Excluding, SemVer.Parse "2.2", SemVer.Parse "3", VersionRangeBound.Excluding).FormatInNuGetSyntax() |> shouldEqual "(2.2,3)"
VersionRange.Range(VersionRangeBound.Excluding, SemVer.Parse "2.2", SemVer.Parse "3", VersionRangeBound.Including).FormatInNuGetSyntax() |> shouldEqual "(2.2,3]"
VersionRange.Range(VersionRangeBound.Including, SemVer.Parse "2.2", SemVer.Parse "3", VersionRangeBound.Excluding).FormatInNuGetSyntax() |> shouldEqual "[2.2,3)"
Expand Down

0 comments on commit 2f863c8

Please sign in to comment.