@@ -8,6 +8,7 @@ module Main ( main ) where
88
99import Data.Either (fromRight , isLeft )
1010import Data.List.NonEmpty (NonEmpty (.. ))
11+ import qualified Data.List.NonEmpty as NonEmpty
1112import qualified Data.Text as T
1213import Data.Versions
1314import Data.Void (Void )
@@ -39,7 +40,7 @@ messes :: [T.Text]
3940messes = [ " 10.2+0.93+1-1" , " 003.03-3" , " 002.000-7" , " 20.26.1_0-2" , " 1.6.0a+2014+m872b87e73dfb-1"
4041 , " 1.3.00.16851-1" , " 5.2.458699.0906-1" , " 12.0.0-3ubuntu1~20.04.5" ]
4142
42- messComps :: [ T. Text]
43+ messComps :: NonEmpty T. Text
4344messComps = [ " 10.2+0.93+1-1" , " 10.2+0.93+1-2" , " 10.2+0.93+2-1"
4445 , " 10.2+0.94+1-1" , " 10.3+0.93+1-1" , " 11.2+0.93+1-1" , " 12"
4546 ]
@@ -67,7 +68,7 @@ goodSemVs = [ "0.1.0", "1.2.3", "1.2.3-1", "1.2.3-alpha", "1.2.3-alpha.2"
6768 ]
6869
6970-- | The exact example from `http://semver.org`
70- semverOrd :: [ T. Text]
71+ semverOrd :: NonEmpty T. Text
7172semverOrd = [ " 1.0.0-alpha" , " 1.0.0-alpha.1" , " 1.0.0-alpha.beta"
7273 , " 1.0.0-beta" , " 1.0.0-beta.2" , " 1.0.0-beta.11" , " 1.0.0-rc.1"
7374 , " 1.0.0"
@@ -78,10 +79,10 @@ semverOrd = [ "1.0.0-alpha", "1.0.0-alpha.1", "1.0.0-alpha.beta"
7879-- make this necessary, meaning `cabal` can't be simplified to ignore it.
7980-- Logically, these are the same package, but for those 5 packages, they
8081-- aren't.
81- cabalOrd :: [ T. Text]
82+ cabalOrd :: NonEmpty T. Text
8283cabalOrd = [ " 0" , " 0.2" , " 0.2.0" , " 0.2.0.0" ]
8384
84- versionOrd :: [ T. Text]
85+ versionOrd :: NonEmpty T. Text
8586versionOrd = [ " 0.9.9.9" , " 1.0.0.0" , " 1.0.0.1" , " 2" ]
8687
8788suite :: TestTree
@@ -95,7 +96,7 @@ suite = testGroup "Tests"
9596 testCase " 1.2.3-alpha.2 == 1.2.3-alpha.2+a1b2c3.1"
9697 (assertBool " Equality test of two complicated SemVers failed"
9798 $ semver " 1.2.3-alpha.2" == semver " 1.2.3-alpha.2+a1b2c3.1" ) :
98- zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp semver a b) semverOrd ( tail semverOrd)
99+ zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp semver a b) ( NonEmpty. toList semverOrd) ( NonEmpty. tail semverOrd)
99100 , testGroup " Whitespace Handling"
100101 [ testCase " 1.2.3-1[ ]" $ parse semver' " semver whitespace" " 1.2.3-1 " @?= Right (SemVer 1 2 3 (Just . Release $ Numeric 1 :| [] ) Nothing )
101102 ]
@@ -105,11 +106,11 @@ suite = testGroup "Tests"
105106 ]
106107 , testGroup " (Haskell) PVP"
107108 [ testGroup " Good PVPs" $
108- map (\ s -> testCase (T. unpack s) $ isomorphPVP s) cabalOrd
109+ map (\ s -> testCase (T. unpack s) $ isomorphPVP s) ( NonEmpty. toList cabalOrd)
109110 , testGroup " Bad PVP" $
110111 map (\ s -> testCase (T. unpack s) $ assertBool " A bad PVP parsed" $ isLeft $ pvp s) badPVP
111112 , testGroup " Comparisons" $
112- zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp pvp a b) cabalOrd ( tail cabalOrd)
113+ zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp pvp a b) ( NonEmpty. toList cabalOrd) ( NonEmpty. tail cabalOrd)
113114 ]
114115 , testGroup " (General) Versions"
115116 [ testGroup " Good Versions" $
@@ -123,15 +124,15 @@ suite = testGroup "Tests"
123124 testCase " 1.1 < 1:1.0" (comp version " 1.1" " 1:1.0" ) :
124125 testCase " 1.1 < 1:1.1" (comp version " 1.1" " 1:1.1" ) :
125126 map (\ (a,b) -> testCase (T. unpack $ a <> " < " <> b) $ comp version a b)
126- (zip cabalOrd ( tail cabalOrd) <> zip versionOrd ( tail versionOrd))
127+ (zip ( NonEmpty. toList cabalOrd) ( NonEmpty. tail cabalOrd) <> zip ( NonEmpty. toList versionOrd) ( NonEmpty. tail versionOrd))
127128 ]
128129 , testGroup " (Complex) Mess"
129130 [ testGroup " Good Versions" $
130131 map (\ s -> testCase (T. unpack s) $ isomorphM s) messes
131132 , testGroup " Bad Versions (shouldn't parse)" $
132133 map (\ s -> testCase (T. unpack s) $ assertBool " A bad version parsed" $ isLeft $ mess s) badVers
133134 , testGroup " Comparisons" $
134- zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp mess a b) messComps ( tail messComps)
135+ zipWith (\ a b -> testCase (T. unpack $ a <> " < " <> b) $ comp mess a b) ( NonEmpty. toList messComps) ( NonEmpty. tail messComps)
135136 , testGroup " SemVer-like Value Extraction"
136137 [ testCase " messMajor" $
137138 (hush (mess " 1.6.0a+2014+m872b87e73dfb-1" ) >>= messMajor) @?= Just 1
0 commit comments