@@ -4,25 +4,35 @@ module Main where
4
4
import Test.HUnit (runTestTT , (~:) , assertEqual , errors , failures , test )
5
5
import Data.Patch ( Patch (apply ) )
6
6
import Data.Patch.MapWithMove ( patchThatChangesMap )
7
+ import Data.Patch.MapWithPatchingMove (PatchMapWithPatchingMove )
8
+ import qualified Data.Patch.MapWithPatchingMove as PatchMapWithPatchingMove
7
9
import Data.Map as Map ( Map , fromList , singleton )
8
10
import Hedgehog (checkParallel , discover , Property , property , forAll , PropertyT , (===) )
9
11
import Hedgehog.Gen as Gen ( int )
10
12
import Hedgehog.Range as Range ( linear )
11
13
import Control.Monad (replicateM )
12
14
import System.Exit (exitFailure , exitSuccess )
13
15
import Data.Sequence as Seq ( foldMapWithIndex , replicateM )
16
+ import Data.Semigroup (Sum (.. ))
14
17
15
18
main :: IO ()
16
19
main = do
17
- counts <- runTestTT $ test [
18
- " Simple Move" ~: ( do
20
+ counts <- runTestTT $ test
21
+ [ " Simple Move" ~: do
19
22
let mapBefore = Map. fromList [(0 ,1 )]
20
23
mapAfter = Map. fromList [(0 ,0 ),(1 ,1 )]
21
24
patch = patchThatChangesMap mapBefore mapAfter
22
25
afterPatch = apply patch mapBefore
23
- assertEqual " Patch creates the same Map" (Just mapAfter) afterPatch),
24
- " Property Checks" ~: propertyChecks
25
- ]
26
+ assertEqual " Patch creates the same Map" (Just mapAfter) afterPatch
27
+ , " Property Checks" ~: propertyChecks
28
+ , " Insert and Patch" ~: do
29
+ let i :: PatchMapWithPatchingMove () (Sum Int )
30
+ i = PatchMapWithPatchingMove. insertMapKey () 1
31
+ p = PatchMapWithPatchingMove. patchMapKey () (Sum 2 )
32
+ pAfterI = PatchMapWithPatchingMove. insertMapKey () 3
33
+ assertEqual " Insert after patch is the same as insert" (i <> p) i
34
+ assertEqual " Patch after insert is a patched insert" (p <> i) pAfterI
35
+ ]
26
36
if errors counts + failures counts == 0 then exitSuccess else exitFailure
27
37
28
38
propertyChecks :: IO Bool
0 commit comments