2 {-# OPTIONS_GHC -fno-warn-deprecations #-}
3 module UnitTests
.Distribution
.CabalSpecVersion
(tests
) where
5 import Distribution
.Compat
.Prelude
.Internal
8 import Distribution
.CabalSpecVersion
9 import Distribution
.FieldGrammar
.Newtypes
(SpecVersion
(..))
10 import Distribution
.Parsec
(eitherParsec
)
11 import Distribution
.Pretty
(prettyShow
)
14 import Test
.Tasty
.QuickCheck
17 import Test
.QuickCheck
.Instances
.Cabal
()
20 tests
= testGroup
"Distribution.CabalSpecVersion"
21 [ testProperty
"roundtrip" propRoundtrip
22 , testProperty
"fromVersionDigits . toVersionDigits = Just" propViaVersionDigits
25 -- we test roundtrip here,
26 -- because Described instance is a small simplification.
27 propRoundtrip
:: SpecVersion
-> Property
28 propRoundtrip x
= counterexample
(show (res
, str
)) $ case res
of
33 res
= eitherParsec str
35 propViaVersionDigits
:: CabalSpecVersion
-> Property
36 propViaVersionDigits csv
=
37 counterexample
(show digits
) $
40 digits
= cabalSpecToVersionDigits csv
41 lhs
= cabalSpecFromVersionDigits digits