git.iko.soy/ikoHSE/sc-task-2
on master help sign in
6 files changed+169−136
since splitsnapshots
unifiedsplit
package.yaml+5−2 src/Task.hs+9−9 stack.yaml+18−2 task.cabal+13−5 test/Main.hs+1−6 test/Tests.hs+123−112
package.yaml+5−2
@@ -2,8 +2,11 @@ name: task
22version: 0.1.0.0
33license: Unlicense
44
5+default-extensions:
6+ - DerivingStrategies
7+
58dependencies:
6− - base >= 4.7 && < 5
9+ - base
710
811library:
912 source-dirs: src
@@ -14,5 +17,5 @@ tests:
1417 main: Main.hs
1518 dependencies:
1619 - tasty
17− - tasty-hspec
20+ - tasty-hunit
1821 - task
src/Task.hs+9−9
@@ -46,7 +46,7 @@ where
4646-- a list of `FirstMonoid`s should return the first element
4747--
4848-- >>> (destructFirstMonoid . fold . fmap constructFirstMonoid) [1, 2, 3]
49−-- Just 3
49+-- Just 1
5050--
5151-- >>> (destructFirstMonoid . fold . fmap constructFirstMonoid) []
5252-- Nothing
@@ -75,7 +75,7 @@ destructFirstMonoid = error "TODO: destructFirstMonoid"
7575-- a list of `LastMonoid`s should return the last element
7676--
7777-- >>> (destructLastMonoid . fold . fmap constructLastMonoid) [1, 2, 3]
78−-- Just 1
78+-- Just 3
7979--
8080-- >>> (destructLastMonoid . fold . fmap constructLastMonoid) []
8181-- Nothing
@@ -105,11 +105,11 @@ destructLastMonoid = error "TODO: destructLastMonoid"
105105
106106-- | The priority of a task.
107107data Priority = Low | Medium | High
108− deriving (Show, Eq)
108+ deriving stock (Show, Eq)
109109
110110-- | The completion status of a task.
111111data Completion = Completed | NotCompleted
112− deriving (Show, Eq, Ord)
112+ deriving stock (Show, Eq, Ord)
113113
114114class TaskManager t where
115115 -- | Returns an empty task manager backend (it should have no tasks).
@@ -194,7 +194,7 @@ data Coffee
194194 -- | The extra ingredients added to the coffee.
195195 extras :: [CoffeeExtra]
196196 }
197− deriving (Eq, Show)
197+ deriving stock (Eq, Show)
198198
199199-- Extra ingredients added to the coffee.
200200data CoffeeExtra
@@ -205,7 +205,7 @@ data CoffeeExtra
205205 | Cinnamon
206206 | WhiteSugar
207207 | BrownSugar
208− deriving (Eq, Show)
208+ deriving stock (Eq, Show)
209209
210210-- | A typeclass representing objects, for which the price can be calculated.
211211class HasPrice x where
@@ -233,7 +233,7 @@ data DebitCard
233233 { balance :: RUBAmount,
234234 cardId :: Int
235235 }
236− deriving (Eq, Show)
236+ deriving stock (Eq, Show)
237237
238238-- | Given a coffee and a debit card, deduce the total price of the coffee from
239239-- the debit card. Return the given debit card with the reduced balance.
@@ -256,7 +256,7 @@ data PaymentMethod
256256 -- (We assume that the person pays with all of the cash he has.)
257257 change :: RUBAmount
258258 }
259− deriving (Eq, Show)
259+ deriving stock (Eq, Show)
260260
261261-- | Represents a coffee shop customer with all of the money he has on him.
262262data Customer
@@ -268,7 +268,7 @@ data Customer
268268 -- | The amount of cash the customer has on him.
269269 cash :: RUBAmount
270270 }
271− deriving (Eq, Show)
271+ deriving stock (Eq, Show)
272272
273273-- You have some new privacy-invading piece of ... technology, which
274274-- automatically scans the customer, determines how he would prefer to pay and
stack.yaml+18−2
@@ -1,7 +1,23 @@
1−resolver: lts-14.27
1+resolver: lts-24.23
22
33packages:
44- .
55
66ghc-options:
7− "$locals": -ddump-to-file -ddump-hi -fwarn-unused-binds -fwarn-unused-imports -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror=missing-home-modules -Wmissing-home-modules -Widentities -Wredundant-constraints -Wmissing-export-lists
7+ "$locals": |
8+ -Weverything
9+ -Wno-unsafe
10+ -Wno-safe
11+ -Wno-missing-safe-haskell-mode
12+ -Wno-missing-import-lists
13+ -Wno-missing-kind-signatures
14+ -Wno-all-missed-specialisations
15+ -Wno-missed-specialisations
16+ -Wno-partial-type-signatures
17+ -Wno-partial-fields
18+ -Wno-operator-whitespace
19+ -Wno-missed-extra-shared-lib
20+ -Wno-missing-role-annotations
21+ -Wno-missing-poly-kind-signatures
22+ -Wno-implicit-prelude
23+ -threaded
task.cabal+13−5
@@ -1,10 +1,10 @@
11cabal-version: 2.2
22
3−-- This file has been generated from package.yaml by hpack version 0.31.2.
3+-- This file has been generated from package.yaml by hpack version 0.37.0.
44--
55-- see: https://github.com/sol/hpack
66--
7−-- hash: c454617de75af64ca6c743a3a745918472bb438f8df9c2019b67700d4caaf63c
7+-- hash: 657afec45539e088a3bf6470712f3a50870d849db61d3f1c453c5d9d2bd91018
88
99name: task
1010version: 0.1.0.0
@@ -17,10 +17,14 @@ library
1717 Task
1818 other-modules:
1919 Paths_task
20+ autogen-modules:
21+ Paths_task
2022 hs-source-dirs:
2123 src
24+ default-extensions:
25+ DerivingStrategies
2226 build-depends:
23− base >=4.7 && <5
27+ base
2428 default-language: Haskell2010
2529
2630test-suite task-tests
@@ -29,11 +33,15 @@ test-suite task-tests
2933 other-modules:
3034 Tests
3135 Paths_task
36+ autogen-modules:
37+ Paths_task
3238 hs-source-dirs:
3339 test
40+ default-extensions:
41+ DerivingStrategies
3442 build-depends:
35− base >=4.7 && <5
43+ base
3644 , task
3745 , tasty
38− , tasty-hspec
46+ , tasty-hunit
3947 default-language: Haskell2010
test/Main.hs+1−6
@@ -4,12 +4,7 @@ module Main
44where
55
66import Test.Tasty
7−import Test.Tasty.Hspec
87import Tests
98
109main :: IO ()
11−main = do
12− tests' <- testSpecs tests
13− defaultMain
14− ( testGroup "tests" tests'
15− )
10+main = defaultMain tests
test/Tests.hs+123−112
@@ -5,33 +5,39 @@ where
55
66import Data.Foldable
77import Data.Function
8−import Data.List
8+import Data.List (sort, groupBy)
99import Task
10−import Test.Tasty.Hspec
10+import Test.Tasty
11+import Test.Tasty.HUnit
1112
12−tests :: Spec
13−tests = do
14− describe "List Monoids" $ do
15− it "FirstMonoid" $ do
16− let getFirst = destructFirstMonoid . fold . fmap constructFirstMonoid
17− getFirst [1 :: Int, 2, 3] `shouldBe` Just 1
18− getFirst [] `shouldBe` (Nothing :: Maybe ())
19− getFirst [True, False] `shouldBe` Just True
20− getFirst [True, True, False] `shouldBe` Just True
21− getFirst [1 .. 1000] `shouldBe` Just (1 :: Int)
22− getFirst [100 .. 1000] `shouldBe` Just (100 :: Int)
23− getFirst [6, 2, 7, 398, 1984, 383, -1020] `shouldBe` Just (6 :: Int)
24− it "LastMonoid" $ do
25− let getLast = destructLastMonoid . fold . fmap constructLastMonoid
26− getLast [1 :: Int, 2, 3] `shouldBe` Just 3
27− getLast [] `shouldBe` (Nothing :: Maybe ())
28− getLast [1 .. 1000] `shouldBe` Just (1000 :: Int)
29− getLast [100 .. 10000] `shouldBe` Just (10000 :: Int)
30− getLast [6, 2, 7, 398, 1984, 383, -1020, 498] `shouldBe` Just (498 :: Int)
31− getLast [True, False] `shouldBe` Just False
32− getLast [True, True, False] `shouldBe` Just False
33− getLast [True, True, False, True] `shouldBe` Just True
34− describe "Todo List" $ do
13+tests :: TestTree
14+tests = testGroup "Tests"
15+ [ testGroup "List Monoids"
16+ [ testCase "FirstMonoid" $ do
17+ let
18+ getFirst :: [a] -> Maybe a
19+ getFirst = destructFirstMonoid . fold . fmap constructFirstMonoid
20+ getFirst [1 :: Int, 2, 3] @=? Just 1
21+ getFirst [] @=? (Nothing :: Maybe ())
22+ getFirst [True, False] @=? Just True
23+ getFirst [True, True, False] @=? Just True
24+ getFirst [1 .. 1000] @=? Just (1 :: Int)
25+ getFirst [100 .. 1000] @=? Just (100 :: Int)
26+ getFirst [6, 2, 7, 398, 1984, 383, -1020] @=? Just (6 :: Int)
27+ , testCase "LastMonoid" $ do
28+ let
29+ getLast :: [a] -> Maybe a
30+ getLast = destructLastMonoid . fold . fmap constructLastMonoid
31+ getLast [1 :: Int, 2, 3] @=? Just 3
32+ getLast [] @=? (Nothing :: Maybe ())
33+ getLast [1 .. 1000] @=? Just (1000 :: Int)
34+ getLast [100 .. 10000] @=? Just (10000 :: Int)
35+ getLast [6, 2, 7, 398, 1984, 383, -1020, 498] @=? Just (498 :: Int)
36+ getLast [True, False] @=? Just False
37+ getLast [True, True, False] @=? Just False
38+ getLast [True, True, False, True] @=? Just True
39+ ]
40+ , testGroup "Todo List" $
3541 let createTasks :: [(String, Priority)] -> MyTaskManager
3642 createTasks = foldl (\t (a, b) -> createTask a b t) emptyTaskManager
3743 getPrioritySets :: MyTaskManager -> [[(Completion, String)]]
@@ -39,9 +45,10 @@ tests = do
3945 fmap (sort . fmap (\(a, _, b) -> (a, b)))
4046 . groupBy ((==) `on` (\(_, p, _) -> p))
4147 . getPriorityList
42− it "emptyTaskManager" $
43− getPriorityList (emptyTaskManager :: MyTaskManager) `shouldBe` []
44− it "createTask" $ do
48+ in
49+ [ testCase "emptyTaskManager" $
50+ getPriorityList (emptyTaskManager :: MyTaskManager) @=? []
51+ , testCase "createTask" $ do
4552 getPrioritySets
4653 ( createTasks
4754 [ ("a", Low),
@@ -49,7 +56,7 @@ tests = do
4956 ("AAAAAAAAAA", High)
5057 ]
5158 )
52− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
59+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
5360 [(NotCompleted, "aaa")],
5461 [(NotCompleted, "a")]
5562 ]
@@ -59,7 +66,7 @@ tests = do
5966 ("AAAAAAAAAA", High)
6067 ]
6168 )
62− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
69+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
6370 [(NotCompleted, "a")]
6471 ]
6572 getPrioritySets
@@ -70,7 +77,7 @@ tests = do
7077 ("oh HaiMark", Medium)
7178 ]
7279 )
73− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
80+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
7481 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
7582 [(NotCompleted, "a")]
7683 ]
@@ -83,11 +90,11 @@ tests = do
8390 ("OH NO", High)
8491 ]
8592 )
86− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
93+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
8794 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
8895 [(NotCompleted, "a")]
8996 ]
90− it "toggleTaskCompletion" $ do
97+ , testCase "toggleTaskCompletion" $ do
9198 getPrioritySets
9299 ( toggleTaskCompletion "AAAAAAAAAA" . createTasks $
93100 [ ("a", Low),
@@ -97,7 +104,7 @@ tests = do
97104 ("OH NO", High)
98105 ]
99106 )
100− `shouldBe` [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
107+ @=? [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
101108 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
102109 [(NotCompleted, "a")]
103110 ]
@@ -110,7 +117,7 @@ tests = do
110117 ("OH NO", High)
111118 ]
112119 )
113− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
120+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
114121 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
115122 [(NotCompleted, "a")]
116123 ]
@@ -126,11 +133,11 @@ tests = do
126133 ("OH NO", High)
127134 ]
128135 )
129− `shouldBe` [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
136+ @=? [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
130137 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
131138 [(Completed, "a")]
132139 ]
133− it "removeTask" $ do
140+ , testCase "removeTask" $ do
134141 getPrioritySets
135142 ( removeTask "AAAAAAAAAA"
136143 . createTasks
@@ -141,7 +148,7 @@ tests = do
141148 ("OH NO", High)
142149 ]
143150 )
144− `shouldBe` [ [(NotCompleted, "OH NO")],
151+ @=? [ [(NotCompleted, "OH NO")],
145152 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
146153 [(NotCompleted, "a")]
147154 ]
@@ -155,7 +162,7 @@ tests = do
155162 ("OH NO", High)
156163 ]
157164 )
158− `shouldBe` [ [(NotCompleted, "OH NO")],
165+ @=? [ [(NotCompleted, "OH NO")],
159166 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
160167 [(NotCompleted, "a")]
161168 ]
@@ -171,10 +178,10 @@ tests = do
171178 ("OH NO", High)
172179 ]
173180 )
174− `shouldBe` [ [(NotCompleted, "OH NO")],
181+ @=? [ [(NotCompleted, "OH NO")],
175182 [(NotCompleted, "a")]
176183 ]
177− it "modifyPriority" $ do
184+ , testCase "modifyPriority" $ do
178185 getPrioritySets
179186 ( modifyPriority "aaa" High . createTasks $
180187 [ ("a", Low),
@@ -184,7 +191,7 @@ tests = do
184191 ("OH NO", High)
185192 ]
186193 )
187− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO"), (NotCompleted, "aaa")],
194+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO"), (NotCompleted, "aaa")],
188195 [(NotCompleted, "oh HaiMark")],
189196 [(NotCompleted, "a")]
190197 ]
@@ -200,7 +207,7 @@ tests = do
200207 ("OH NO", High)
201208 ]
202209 )
203− `shouldBe` [ [ (Completed, "a"),
210+ @=? [ [ (Completed, "a"),
204211 (NotCompleted, "AAAAAAAAAA"),
205212 (NotCompleted, "OH NO"),
206213 (NotCompleted, "aaa")
@@ -220,7 +227,7 @@ tests = do
220227 ("OH NO", High)
221228 ]
222229 )
223− `shouldBe` [ [ (NotCompleted, "AAAAAAAAAA"),
230+ @=? [ [ (NotCompleted, "AAAAAAAAAA"),
224231 (NotCompleted, "OH NO"),
225232 (NotCompleted, "a"),
226233 (NotCompleted, "aaa"),
@@ -230,7 +237,7 @@ tests = do
230237 getPrioritySets
231238 ( modifyPriority "aaa" High
232239 . modifyPriority "a" High
233− . modifyPriority "nit here sihji" High
240+ . modifyPriority "ntestCase here sihji" High
234241 . modifyPriority "oh HaiMark" Low
235242 . modifyPriority "a" High
236243 . modifyPriority "oh HaiMark" High
@@ -242,14 +249,14 @@ tests = do
242249 ("OH NO", High)
243250 ]
244251 )
245− `shouldBe` [ [ (NotCompleted, "AAAAAAAAAA"),
252+ @=? [ [ (NotCompleted, "AAAAAAAAAA"),
246253 (NotCompleted, "OH NO"),
247254 (NotCompleted, "a"),
248255 (NotCompleted, "aaa")
249256 ],
250257 [(NotCompleted, "oh HaiMark")]
251258 ]
252− it "renameTask" $ do
259+ , testCase "renameTask" $ do
253260 getPrioritySets
254261 ( renameTask "AAAAAAAAAA" "henlo"
255262 . createTasks
@@ -260,7 +267,7 @@ tests = do
260267 ("OH NO", High)
261268 ]
262269 )
263− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
270+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
264271 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
265272 [(NotCompleted, "a")]
266273 ]
@@ -276,7 +283,7 @@ tests = do
276283 ("OH NO", High)
277284 ]
278285 )
279− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
286+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
280287 [(NotCompleted, "aaa"), (NotCompleted, "iz task")],
281288 [(Completed, "a")]
282289 ]
@@ -293,86 +300,88 @@ tests = do
293300 ("OH NO", High)
294301 ]
295302 )
296− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
303+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
297304 [(Completed, "iz task"), (NotCompleted, "aaa")],
298305 [(NotCompleted, "a")]
299306 ]
300− describe "Coffee" $ do
301− it "HasPrice Coffee" $ do
302− price (Coffee 2 [OatMilk, Cinnamon]) `shouldBe` 2 + price OatMilk + price Cinnamon
303− price (Coffee 2 [Cinnamon, Cinnamon]) `shouldBe` 2 + price Cinnamon + price Cinnamon
304− price (Coffee 2 []) `shouldBe` 2
307+ ]
308+ , testGroup "Coffee"
309+ [ testCase "HasPrice Coffee" $ do
310+ price (Coffee 2 [OatMilk, Cinnamon]) @=? 2 + price OatMilk + price Cinnamon
311+ price (Coffee 2 [Cinnamon, Cinnamon]) @=? 2 + price Cinnamon + price Cinnamon
312+ price (Coffee 2 []) @=? 2
305313 price (Coffee 2 [Cinnamon, Cream, Cinnamon])
306− `shouldBe` 2
314+ @=? 2
307315 + price Cinnamon
308316 + price Cinnamon
309317 + price Cream
310− it "chargeCoffee" $ do
318+ , testCase "chargeCoffee" $ do
311319 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 199 69)
312− `shouldBe` Just (DebitCard 112 69)
320+ @=? Just (DebitCard 112 69)
313321 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 87 69)
314− `shouldBe` Just (DebitCard 0 69)
322+ @=? Just (DebitCard 0 69)
315323 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 86 69)
316− `shouldBe` Nothing
324+ @=? Nothing
317325 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 0 69)
318− `shouldBe` Nothing
326+ @=? Nothing
319327 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard (-2189) 69)
320− `shouldBe` Nothing
328+ @=? Nothing
321329 chargeCoffee (Coffee 2 [OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
322− `shouldBe` Just (DebitCard 97 69)
330+ @=? Just (DebitCard 97 69)
323331 chargeCoffee (Coffee 2 [WhiteSugar, OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
324− `shouldBe` Just (DebitCard 82 69)
325− let coffee = Coffee 2 [OatMilk, Cinnamon]
326− it "payForCoffee" $ do
327− payForCoffee (Customer [DebitCard 199 69] 0) coffee
328− `shouldBe` Just (Card (DebitCard 112 69))
329− payForCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
330− `shouldBe` Just (Card (DebitCard 112 69))
331− payForCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
332− `shouldBe` Just (Card (DebitCard 112 69))
333− payForCoffee (Customer [DebitCard 87 8, DebitCard 111 12, DebitCard 199 69] 0) coffee
334− `shouldBe` Just (Card (DebitCard 0 8))
335− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0) coffee
336− `shouldBe` Nothing
337− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
338− `shouldBe` Just (Cash 0)
339− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
340− `shouldBe` Nothing
341− it "applyPayment" $ do
332+ @=? Just (DebitCard 82 69)
333+ , let coffee = Coffee 2 [OatMilk, Cinnamon]
334+ in testCase "payForCoffee" $ do
335+ payForCoffee (Customer [DebitCard 199 69] 0) coffee
336+ @=? Just (Card (DebitCard 112 69))
337+ payForCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
338+ @=? Just (Card (DebitCard 112 69))
339+ payForCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
340+ @=? Just (Card (DebitCard 112 69))
341+ payForCoffee (Customer [DebitCard 87 8, DebitCard 111 12, DebitCard 199 69] 0) coffee
342+ @=? Just (Card (DebitCard 0 8))
343+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0) coffee
344+ @=? Nothing
345+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
346+ @=? Just (Cash 0)
347+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
348+ @=? Nothing
349+ , testCase "applyPayment" $ do
342350 applyPayment (Customer [DebitCard 199 69] 0) (Card (DebitCard 112 69))
343− `shouldBe` Customer [DebitCard 112 69] 0
351+ @=? Customer [DebitCard 112 69] 0
344352 applyPayment (Customer [DebitCard 111 12, DebitCard 199 69] 2) (Card (DebitCard 112 69))
345− `shouldBe` Customer [DebitCard 111 12, DebitCard 112 69] 2
353+ @=? Customer [DebitCard 111 12, DebitCard 112 69] 2
346354 applyPayment (Customer [DebitCard (-12) 8, DebitCard 111 12, DebitCard 199 69] 0) (Card (DebitCard 112 69))
347− `shouldBe` Customer [DebitCard (-12) 8, DebitCard 111 12, DebitCard 112 69] 0
355+ @=? Customer [DebitCard (-12) 8, DebitCard 111 12, DebitCard 112 69] 0
348356 applyPayment (Customer [DebitCard 112 8, DebitCard 111 12, DebitCard 199 69] 0) (Card (DebitCard 0 8))
349− `shouldBe` Customer [DebitCard 0 8, DebitCard 111 12, DebitCard 199 69] 0
357+ @=? Customer [DebitCard 0 8, DebitCard 111 12, DebitCard 199 69] 0
350358 applyPayment (Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112) (Cash 0)
351− `shouldBe` Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 0
359+ @=? Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 0
352360 applyPayment (Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112) (Card (DebitCard 0 13))
353− `shouldBe` Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112
354− it "buyCoffee" $ do
355− buyCoffee (Customer [DebitCard 199 69] 0) coffee
356− `shouldBe` Just (Customer [DebitCard 112 69] 0)
357− buyCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
358− `shouldBe` Just (Customer [DebitCard 86 12, DebitCard 112 69] 2)
359− buyCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
360− `shouldBe` Just (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 112 69] 0)
361− buyCoffee (Customer [DebitCard 87 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
362− `shouldBe` Just (Customer [DebitCard 0 8, DebitCard 86 12, DebitCard 199 69] 0)
363− buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 84 69] 0) coffee
364− `shouldBe` Nothing
365− buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
366− `shouldBe` Just (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0)
367− buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
368− `shouldBe` Nothing
369− it "saveTheDiabetic" $ do
361+ @=? Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112
362+ , let coffee = Coffee 2 [OatMilk, Cinnamon]
363+ in testCase "buyCoffee" $ do
364+ buyCoffee (Customer [DebitCard 199 69] 0) coffee
365+ @=? Just (Customer [DebitCard 112 69] 0)
366+ buyCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
367+ @=? Just (Customer [DebitCard 86 12, DebitCard 112 69] 2)
368+ buyCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
369+ @=? Just (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 112 69] 0)
370+ buyCoffee (Customer [DebitCard 87 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
371+ @=? Just (Customer [DebitCard 0 8, DebitCard 86 12, DebitCard 199 69] 0)
372+ buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 84 69] 0) coffee
373+ @=? Nothing
374+ buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
375+ @=? Just (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0)
376+ buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
377+ @=? Nothing
378+ , testCase "saveTheDiabetic" $ do
370379 saveTheDiabetic
371380 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
372381 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
373382 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
374383 ]
375− `shouldBe` ( 150,
384+ @=? ( 150,
376385 [ Coffee 0 [Cinnamon],
377386 Coffee 0 [Cinnamon],
378387 Coffee 0 [Cinnamon]
@@ -383,7 +392,7 @@ tests = do
383392 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
384393 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
385394 ]
386− `shouldBe` ( 215,
395+ @=? ( 215,
387396 [ Coffee 0 [Cinnamon, SoyMilk],
388397 Coffee 0 [Cinnamon],
389398 Coffee 0 [Cinnamon]
@@ -395,7 +404,7 @@ tests = do
395404 Coffee 0 [Cinnamon],
396405 Coffee 69 []
397406 ]
398− `shouldBe` ( 0,
407+ @=? ( 0,
399408 [ Coffee 0 [Cinnamon, SoyMilk],
400409 Coffee 0 [Cinnamon],
401410 Coffee 0 [Cinnamon],
@@ -404,29 +413,31 @@ tests = do
404413 )
405414 saveTheDiabetic
406415 []
407− `shouldBe` ( 0,
416+ @=? ( 0,
408417 []
409418 )
410− it "calculateSugarDanger" $ do
419+ , testCase "calculateSugarDanger" $ do
411420 calculateSugarDanger
412421 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
413422 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
414423 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
415424 ]
416− `shouldBe` 9
425+ @=? 9
417426 calculateSugarDanger
418427 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon, BrownSugar, SoyMilk],
419428 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
420429 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
421430 Coffee 0 []
422431 ]
423− `shouldBe` 14
432+ @=? 14
424433 calculateSugarDanger
425434 [ Coffee 0 [Cinnamon, SoyMilk],
426435 Coffee 0 [Cinnamon],
427436 Coffee 0 [Cinnamon]
428437 ]
429− `shouldBe` 0
438+ @=? 0
430439 calculateSugarDanger
431440 []
432− `shouldBe` 0
441+ @=? 0
442+ ]
443+ ]