Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of
Items is over 30.00 (let's not delve into the fact that I'm using a
Float to indicate the price):
promoGet30PercentOff :: [Item] -> Float promoGet30PercentOff xs | total > 30.0 = total * 0.7 | otherwise = total where total = sum $ map itemPrice xs
itemPrice are defined as follows:
data Item = Apple | Banana deriving Show itemPrice :: Item -> Float itemPrice x = case x of Apple -> 5.9 Banana -> 3.0
I'd now like to test
promoGet30PercentOff at the boundary.
As I come from Python, my natural reaction would be to mock
Item and create some that are priced at 30.0, 30.1 and 0.0, for instance.
I believe, this is not possible in Haskell (but correct me if I'm wrong). How would you go about it then?