Skip to content

Commit

Permalink
SCP-5126 Elaborated comments on MList property tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Mar 1, 2023
1 parent e227767 commit a95a616
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions marlowe-test/src/Spec/Marlowe/Plutus/MList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,22 @@ tests =
]


-- | Generate a sorted `MList` with no duplicates.
-- | Generate a sorted `MList` with no duplicate keys.
arbitraryMList :: Gen (MList Integer [()])
arbitraryMList = nubBy ((==) `on` fst) . sortBy (compare `on` fst) <$> arbitrary


-- | Compare an `MList` to an `AssocMap`.
-- | Compare an `MList` to an `AssocMap`, ignoring ordering.
equivalent :: Ord a => Eq b => MList a b -> AM.Map a b -> Bool
equivalent mlist assocmap = mlist == sortBy (compare `on` fst) (AM.toList assocmap)


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `empty` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkEmpty :: Assertion
checkEmpty = assertBool "Empty MList and AssocMap" $ (empty :: MList [()] Integer) `equivalent` AM.empty


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `null` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkNull :: Property
checkNull = property $ do
let
Expand All @@ -202,7 +202,7 @@ checkNull = property $ do
$ \(mlist, assocmap) -> (== empty) mlist == AM.null assocmap


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `singleton` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkSingleton :: Property
checkSingleton = property $ do
let
Expand All @@ -214,7 +214,7 @@ checkSingleton = property $ do
$ \(a, b) -> [(a, b)] `equivalent` AM.singleton a b


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `insert` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkInsert :: Property
checkInsert = property $ do
let
Expand All @@ -228,7 +228,7 @@ checkInsert = property $ do
$ \(mlist, assocmap, a, b) -> insert a b mlist `equivalent` AM.insert a b assocmap


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `delete` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkDelete :: Property
checkDelete = property $ do
let
Expand All @@ -241,7 +241,7 @@ checkDelete = property $ do
$ \(mlist, assocmap, a) -> delete a mlist `equivalent` AM.delete a assocmap


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `lookup` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkLookup :: Property
checkLookup = property $ do
let
Expand All @@ -254,7 +254,7 @@ checkLookup = property $ do
$ \(mlist, assocmap, a) -> lookup a mlist == AM.lookup a assocmap


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `member` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkMember :: Property
checkMember = property $ do
let
Expand All @@ -267,7 +267,7 @@ checkMember = property $ do
$ \(mlist, assocmap, a) -> isJust (lookup a mlist) == AM.member a assocmap


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `unionWith` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkUnionWith :: Property
checkUnionWith = property $ do
let
Expand All @@ -291,7 +291,7 @@ checkUnionWith = property $ do
unionWith f mlist mlist' `equivalent` AM.unionWith f assocmap assocmap'


-- | Compare `empty` for `MList` and `AssocMap`.
-- | Compare `findWithDefault` for `MList` and `AssocMap`, provided the `MList` is sorted and neither contains duplicate keys.
checkFindWithDefault :: Property
checkFindWithDefault = property $ do
let
Expand Down

0 comments on commit a95a616

Please sign in to comment.