Correctly provision build tools in all situations
[cabal.git] / Cabal-tests / tests / UnitTests / Distribution / Utils / Structured.hs
blob641551473e8ce31cc3d9eb7be46216dfd9d8942f
1 {-# LANGUAGE CPP #-}
2 module UnitTests.Distribution.Utils.Structured (tests) where
4 import Data.Proxy (Proxy (..))
5 import Distribution.Utils.MD5 (md5FromInteger)
6 import Distribution.Utils.Structured (structureHash, Structured)
7 import Test.Tasty (TestTree, testGroup)
8 import Test.Tasty.HUnit (testCase, (@?=), Assertion)
10 import Distribution.SPDX.License (License)
11 import Distribution.Types.VersionRange (VersionRange)
13 import Distribution.Types.GenericPackageDescription (GenericPackageDescription)
14 import Distribution.Types.LocalBuildInfo (LocalBuildInfo)
16 import UnitTests.Orphans ()
18 tests :: TestTree
19 tests = testGroup "Distribution.Utils.Structured"
20 -- This test also verifies that structureHash doesn't loop.
21 [ testCase "VersionRange" $
22 md5Check (Proxy :: Proxy VersionRange) 0x39396fc4f2d751aaa1f94e6d843f03bd
23 , testCase "SPDX.License" $
24 md5Check (Proxy :: Proxy License) 0xd3d4a09f517f9f75bc3d16370d5a853a
25 -- The difference is in encoding of newtypes
26 , testCase "GenericPackageDescription" $ md5CheckGenericPackageDescription (Proxy :: Proxy GenericPackageDescription)
27 , testCase "LocalBuildInfo" $ md5CheckLocalBuildInfo (Proxy :: Proxy LocalBuildInfo)
30 md5Check :: Structured a => Proxy a -> Integer -> Assertion
31 md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int
33 md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion
34 md5CheckGenericPackageDescription proxy = md5Check proxy
35 #if MIN_VERSION_base(4,19,0)
36 0x4acd7857947385180d814f36dc1a759e
37 #else
38 0x3ff3fa6c3c570bcafa10b457b1208cc8
39 #endif
41 md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion
42 md5CheckLocalBuildInfo proxy = md5Check proxy
43 #if MIN_VERSION_base(4,19,0)
44 0x552eca9ce2e4a34e74deff571f279fc4
45 #else
46 0x48497d6b3f15df06f1107b81b98febe1
47 #endif