1 module UnitTests
.Distribution
.Client
.IndexUtils
where
3 import Distribution
.Client
.IndexUtils
4 import qualified Distribution
.Compat
.NonEmptySet
as NES
5 import Distribution
.Simple
.Utils
(toUTF8LBS
)
6 import Distribution
.Types
.Dependency
7 import Distribution
.Types
.LibraryName
8 import Distribution
.Types
.PackageName
9 import Distribution
.Version
12 import Test
.Tasty
.HUnit
16 [ simpleVersionsParserTests
19 simpleVersionsParserTests
:: TestTree
20 simpleVersionsParserTests
=
22 "Simple preferred-versions Parser Tests"
23 [ testCase
"simple deprecation dependency" $ do
24 let prefs
= parsePreferredVersionsWarnings
(toUTF8LBS
"binary < 0.9.0.0 || > 0.9.0.0")
28 (mkPackageName
"binary")
30 (earlierVersion
$ mkVersion
[0, 9, 0, 0])
31 (laterVersion
$ mkVersion
[0, 9, 0, 0])
33 (NES
.singleton LMainLibName
)
36 , testCase
"multiple deprecation dependency" $ do
37 let prefs
= parsePreferredVersionsWarnings
(toUTF8LBS
"binary < 0.9.0.0 || > 0.9.0.0\ncontainers == 0.6.4.1")
41 (mkPackageName
"binary")
43 (earlierVersion
$ mkVersion
[0, 9, 0, 0])
44 (laterVersion
$ mkVersion
[0, 9, 0, 0])
46 (NES
.singleton LMainLibName
)
50 (mkPackageName
"containers")
51 (thisVersion
$ mkVersion
[0, 6, 4, 1])
52 (NES
.singleton LMainLibName
)
55 , testCase
"unparsable dependency" $ do
56 let prefs
= parsePreferredVersionsWarnings
(toUTF8LBS
"binary 0.9.0.0 || > 0.9.0.0")
58 @?
= [ Left binaryDepParseError
60 , testCase
"partial parse" $ do
61 let prefs
= parsePreferredVersionsWarnings
(toUTF8LBS
"binary 0.9.0.0 || > 0.9.0.0\ncontainers == 0.6.4.1")
63 @?
= [ Left binaryDepParseError
66 (mkPackageName
"containers")
67 (thisVersion
$ mkVersion
[0, 6, 4, 1])
68 (NES
.singleton LMainLibName
)
74 PreferredVersionsParseError
75 { preferredVersionsParsecError
=
77 [ "\"<eitherParsec>\" (line 1, column 8):\n"
79 , "expecting space, white space, opening paren, operator or end of input"
81 , preferredVersionsOriginalDependency
= "binary 0.9.0.0 || > 0.9.0.0"