1{-# LANGUAGE TemplateHaskell #-}
4import Test.HUnit (runTestTT, (~:), assertEqual, errors, failures, test)
5import Data.Patch ( Patch(apply) )
6import Data.Patch.MapWithMove ( patchThatChangesMap )
7import Data.Map as Map ( Map, fromList, singleton )
8import Hedgehog (checkParallel, discover, Property, property, forAll, PropertyT, (===))
9import Hedgehog.Gen as Gen ( int )
10import Hedgehog.Range as Range ( linear )
11import Control.Monad (replicateM)
12import System.Exit (exitFailure, exitSuccess)
13import Data.Sequence as Seq ( foldMapWithIndex, replicateM )
17 counts <- runTestTT $ test [
19 let mapBefore = Map.fromList [(0,1)]
20 mapAfter = Map.fromList [(0,0),(1,1)]
21 patch = patchThatChangesMap mapBefore mapAfter
22 afterPatch = apply patch mapBefore
23 assertEqual "Patch creates the same Map" (Just mapAfter) afterPatch),
24 "Property Checks" ~: propertyChecks
26 if errors counts + failures counts == 0 then exitSuccess else exitFailure
28propertyChecks :: IO Bool
29propertyChecks = checkParallel $$(discover)
31prop_patchThatChangesMap :: Property
32prop_patchThatChangesMap = property $ do
33 mapBefore <- makeRandomIntMap
34 mapAfter <- makeRandomIntMap
35 let patch = patchThatChangesMap mapBefore mapAfter
36 Just mapAfter === apply patch mapBefore
38makeRandomIntMap :: Monad m => PropertyT m (Map Int Int)
40 let genNum = Gen.int (Range.linear 0 100)
41 length <- forAll genNum
42 listOfNumbers <- forAll $ Seq.replicateM length genNum
43 pure $ Seq.foldMapWithIndex Map.singleton listOfNumbers
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list