-
Notifications
You must be signed in to change notification settings - Fork 740
Expand file tree
/
Copy pathStructured.hs
More file actions
36 lines (29 loc) · 1.64 KB
/
Copy pathStructured.hs
File metadata and controls
36 lines (29 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module UnitTests.Distribution.Utils.Structured (tests) where
import Data.Proxy (Proxy (..))
import Distribution.Utils.MD5 (md5FromInteger)
import Distribution.Utils.Structured (structureHash, Structured)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase, (@?=), Assertion)
import Distribution.SPDX.License (License)
import Distribution.Types.VersionRange (VersionRange)
import Distribution.Types.GenericPackageDescription (GenericPackageDescription)
import Distribution.Types.LocalBuildInfo (LocalBuildInfo)
tests :: TestTree
tests = testGroup "Distribution.Utils.Structured"
-- This test also verifies that structureHash doesn't loop.
[ testCase "VersionRange" $
md5Check (Proxy :: Proxy VersionRange) 0x39396fc4f2d751aaa1f94e6d843f03bd
, testCase "SPDX.License" $
md5Check (Proxy :: Proxy License) 0x2804cd5d2137508059c16ac2449741d2
-- The difference is in encoding of newtypes
, testCase "GenericPackageDescription" $ md5CheckGenericPackageDescription (Proxy :: Proxy GenericPackageDescription)
, testCase "LocalBuildInfo" $ md5CheckLocalBuildInfo (Proxy :: Proxy LocalBuildInfo)
]
md5Check :: Structured a => Proxy a -> Integer -> Assertion
md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int
md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion
md5CheckGenericPackageDescription proxy = md5Check proxy
0xfbca1c1f2a700fb3a174ec5346e86cbb
md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion
md5CheckLocalBuildInfo proxy = md5Check proxy
0x3bf7bf1420847ce5fdaf6e36e33aecb2