versions 4.0.1 → 4.0.2
raw patch · 4 files changed
+28/−12 lines, 4 files
Files
- CHANGELOG.md +8/−0
- Data/Versions.hs +13/−9
- test/Test.hs +6/−2
- versions.cabal +1/−1
CHANGELOG.md view
@@ -1,5 +1,13 @@ # Changelog +## 4.0.2 (2021-01-23)++#### Fixed++- A bug in zero parsing within SemVer prereleases. [#42]++[#42]: https://github.com/fosskers/versions/issues/42+ ## 4.0.1 (2020-10-22) #### Fixed
Data/Versions.hs view
@@ -788,17 +788,21 @@ -- since a version like @1.000.1@ would parse as @1.0.1@. chunk :: Parsec Void Text VChunk chunk = try zeroWithLetters <|> oneZero <|> PC.some (iunit <|> sunit)- where oneZero = (:|[]) . Digits . read . T.unpack <$> string "0"- zeroWithLetters = do- z <- Digits . read . T.unpack <$> string "0"- s <- PC.some sunit- c <- optional chunk- case c of- Nothing -> pure $ NEL.cons z s- Just c' -> pure $ NEL.cons z s <> c'+ where+ oneZero :: Parsec Void Text (NonEmpty VUnit)+ oneZero = (Digits 0 :| []) <$ single '0' + zeroWithLetters :: Parsec Void Text (NonEmpty VUnit)+ zeroWithLetters = do+ z <- Digits 0 <$ single '0'+ s <- PC.some sunit+ c <- optional chunk+ case c of+ Nothing -> pure $ NEL.cons z s+ Just c' -> pure $ NEL.cons z s <> c'+ iunit :: Parsec Void Text VUnit-iunit = Digits . read <$> some digitChar+iunit = Digits <$> ((0 <$ single '0') <|> (read <$> some digitChar)) sunit :: Parsec Void Text VUnit sunit = Str . T.pack <$> some letterChar
test/Test.hs view
@@ -78,7 +78,7 @@ goodSemVs :: [T.Text] goodSemVs = [ "0.1.0", "1.2.3", "1.2.3-1", "1.2.3-alpha", "1.2.3-alpha.2"- , "1.2.3+a1b2c3.1", "1.2.3-alpha.2+a1b2c3.1"+ , "1.2.3+a1b2c3.1", "1.2.3-alpha.2+a1b2c3.1", "2.2.1-b05" ] -- | The exact example from `http://semver.org`@@ -122,6 +122,10 @@ , testGroup "Whitespace Handling" [ testCase "1.2.3-1[ ]" $ parse semver' "semver whitespace" "1.2.3-1 " @?= Right (SemVer 1 2 3 [[Digits 1]] []) ]+ , testGroup "Zero Handling"+ [ testCase "2.2.1-b05" $ semver "2.2.1-b05" @?= Right (SemVer 2 2 1 [[Str "b", Digits 0, Digits 5]] [])++ ] ] , testGroup "(Haskell) PVP" [ testGroup "Good PVPs" $@@ -260,7 +264,7 @@ comp f a b = check $ (<) <$> f a <*> f b equal :: Ord r => (T.Text -> Either l r) -> T.Text -> Assertion-equal f a = check $ (\r -> compare r r == EQ) <$> f a+equal f a = check $ (\r -> r == r) <$> f a check :: Either a Bool -> Assertion check = assertBool "Some Either-based assertion failed" . either (const False) id
versions.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: versions-version: 4.0.1+version: 4.0.2 synopsis: Types and parsers for software version numbers. description: A library for parsing and comparing software version numbers. We like to give