Skip to content

Commit

Permalink
Adding prerelease specs
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 21, 2015
1 parent eb475dd commit 47346f5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Paket.Core/SemVer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type PreRelease =
match yobj with
| :? PreRelease as y -> x.Origin = y.Origin
| _ -> false

override x.ToString() = x.Origin

override x.GetHashCode() = hash x.Origin
interface System.IComparable with
Expand Down Expand Up @@ -171,7 +173,7 @@ module SemVer =
let firstDash = version.IndexOf("-")
let plusIndex = version.IndexOf("+")

let majorMinorPatch =
let majorMinorPatch =
let firstSigil = if firstDash > 0 then firstDash else plusIndex
match firstSigil with
| -1 -> version
Expand All @@ -181,7 +183,7 @@ module SemVer =
match firstDash, plusIndex with
| -1, _ -> ""
| d, p when p = -1 -> version.Substring(d+1)
| d, p -> version.Substring(d+1, (version.Length - 1 - p) )
| d, p -> version.Substring(d+1, (version.Length - 1 - p) )

/// there can only be one piece of build metadata, and it is signified by a + and then any number of dot-separated alphanumeric groups.
/// this just greedily takes the whole remaining string :(
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<StartArguments>update group Build</StartArguments>
<StartArguments>pack output D:\code\paketbug\output</StartArguments>
<StartArguments>install</StartArguments>
<StartArguments>update -f</StartArguments>
<StartArguments>update</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paketkopie</StartWorkingDirectory>
Expand Down
25 changes: 25 additions & 0 deletions tests/Paket.Tests/SemVerSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ let ``can normalize CI versions in prerelease``() =
let ``should parse very large prerelease numbers (aka timestamps)``() =
(SemVer.Parse "0.22.0-pre20150223185624").Normalize() |> shouldEqual "0.22.0-pre20150223185624"

[<Test>]
let ``should parse paket prerelease versions``() =
let v = SemVer.Parse "1.2.3-alpha002"

v.Major |> shouldEqual 1u
v.Minor |> shouldEqual 2u
v.Patch |> shouldEqual 3u
v.PreRelease.Value.ToString() |> shouldEqual "alpha002"
v.PreRelease.Value.Name |> shouldEqual "alpha"


[<Test>]
let ``should parse CoreClr prerelease versions``() =
let v = SemVer.Parse "1.2.3-beta-22819"

v.Major |> shouldEqual 1u
v.Minor |> shouldEqual 2u
v.Patch |> shouldEqual 3u
v.PreRelease.Value.ToString() |> shouldEqual "beta-22819"
v.PreRelease.Value.Name |> shouldEqual "beta"

[<Test>]
let ``should compare CoreClr prerelease versions``() =
(SemVer.Parse "1.2.3-beta-22819") |> shouldBeGreaterThan (SemVer.Parse "1.2.3-beta-22818")
(SemVer.Parse "1.2.3-beta-22817") |> shouldBeSmallerThan (SemVer.Parse "1.2.3-beta-22818")

[<Test>]
let ``version core elements must be non-negative (SemVer 2.0.0/2)`` () =
Expand Down

0 comments on commit 47346f5

Please sign in to comment.