Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Jul 29, 2021
1 parent 73d0ff6 commit 2e55f67
Showing 1 changed file with 16 additions and 21 deletions.
Expand Up @@ -24,8 +24,6 @@ import Cardano.Wallet.Primitive.Types.Coin
( Coin (..) )
import Data.Either
( isLeft, isRight )
import Data.List.NonEmpty
( NonEmpty )
import Data.Map.Strict
( Map )
import Data.Set
Expand Down Expand Up @@ -57,7 +55,6 @@ import Test.QuickCheck
import qualified Data.Bits as Bits
import qualified Data.Foldable as F
import qualified Data.List as L
import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set

Expand Down Expand Up @@ -379,35 +376,33 @@ prop_takeUntil_head xs =
where
result = takeUntil (const True) xs

prop_takeUntil_singleton :: NonEmpty () -> Property
prop_takeUntil_singleton xs =
conjoin
[ takeUntil (const True ) (NE.toList xs) === [()]
, takeUntil (const False) (NE.toList xs) === [()]
]

prop_takeUntil_takeWhile :: [Int] -> Property
prop_takeUntil_takeWhile xs =
checkCoverage $
cover 20.0
(length takeUntilResult == 1 && length takeWhileResult < length xs)
"length takeUntilResult == 1 && length takeWhileResult < length xs" $
cover 40.0
(length takeUntilResult >= 2 && length takeWhileResult < length xs)
"length takeUntilResult >= 2 && length takeWhileResult < length xs" $
cover 40.0
(length takeUntilResult > length takeWhileResult)
"length takeUntilResult > length takeWhileResult" $
cover 80.0
(takeWhileLength < takeUntilLength && takeUntilLength < length xs)
"takeWhileLength < takeUntilLength && takeUntilLength < length xs" $
cover 2.0
(takeWhileLength < takeUntilLength && takeUntilLength == length xs)
"takeWhileLength < takeUntilLength && takeUntilLength == length xs" $
cover 2.0
(takeWhileLength == takeUntilLength && takeUntilLength == length xs)
"takeWhileLength == takeUntilLength && takeUntilLength == length xs" $
conjoin
[ takeWhileResult `L.isPrefixOf` xs
, takeUntilResult `L.isPrefixOf` xs
, (drop (length takeWhileResult) takeUntilResult) == take 1
(drop (length takeWhileResult) xs)
, all (not . condition) takeWhileResult
, all (not . condition) (take takeWhileLength takeUntilResult)
, all ( condition) (drop takeWhileLength takeUntilResult)
, (drop takeWhileLength takeUntilResult) == take 1
(drop takeWhileLength xs)
]
where
condition = ((== 0) . (`mod` 4))
takeUntilResult = takeUntil ( condition) xs
takeWhileResult = takeWhile (not . condition) xs
takeUntilLength = length takeUntilResult
takeWhileLength = length takeWhileResult

--------------------------------------------------------------------------------
-- Utility functions
Expand Down

0 comments on commit 2e55f67

Please sign in to comment.