git.iko.soy/ikoHSE/sc-task-2
on master help sign in
nightly-2024-10-11 and hunit
0f050abiko
package.yaml+1−1
@@ -14,5 +14,5 @@ tests:
14 main: Main.hs
14 main: Main.hs
15 dependencies:
15 dependencies:
16 - tasty
16 - tasty
17− - tasty-hspec
17+ - tasty-hunit
18 - task
18 - task
stack.yaml+1−1
@@ -1,4 +1,4 @@
1−resolver: lts-14.27
1+resolver: nightly-2024-10-11
2
2
3packages:
3packages:
4- .
4- .
task.cabal+7−3
@@ -1,10 +1,10 @@
1cabal-version: 2.2
1cabal-version: 2.2
2
2
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.36.0.
4--
4--
5-- see: https://github.com/sol/hpack
5-- see: https://github.com/sol/hpack
6--
6--
7−-- hash: c454617de75af64ca6c743a3a745918472bb438f8df9c2019b67700d4caaf63c
7+-- hash: e7ce4d16c67bf724ae661c06d421b31bdf4a8955874528858483b7ed2f59e002
8
8
9name: task
9name: task
10version: 0.1.0.0
10version: 0.1.0.0
@@ -17,6 +17,8 @@ library
17 Task
17 Task
18 other-modules:
18 other-modules:
19 Paths_task
19 Paths_task
20+ autogen-modules:
21+ Paths_task
20 hs-source-dirs:
22 hs-source-dirs:
21 src
23 src
22 build-depends:
24 build-depends:
@@ -29,11 +31,13 @@ test-suite task-tests
29 other-modules:
31 other-modules:
30 Tests
32 Tests
31 Paths_task
33 Paths_task
34+ autogen-modules:
35+ Paths_task
32 hs-source-dirs:
36 hs-source-dirs:
33 test
37 test
34 build-depends:
38 build-depends:
35 base >=4.7 && <5
39 base >=4.7 && <5
36 , task
40 , task
37 , tasty
41 , tasty
38− , tasty-hspec
42+ , tasty-hunit
39 default-language: Haskell2010
43 default-language: Haskell2010
test/Main.hs+1−6
@@ -4,12 +4,7 @@ module Main
4where
4where
5
5
6import Test.Tasty
6import Test.Tasty
7−import Test.Tasty.Hspec
8import Tests
7import Tests
9
8
10main :: IO ()
9main :: IO ()
11−main = do
12− tests' <- testSpecs tests
13− defaultMain
10+main = defaultMain tests
14− ( testGroup "tests" tests'
15− )
test/Tests.hs+116−109
@@ -7,31 +7,33 @@ import Data.Foldable
7import Data.Function
7import Data.Function
8import Data.List
8import Data.List
9import Task
9import Task
10−import Test.Tasty.Hspec
10+import Test.Tasty
11+import Test.Tasty.HUnit
11
12
12−tests :: Spec
13+tests :: TestTree
13−tests = do
14+tests = testGroup "Tests"
14− describe "List Monoids" $ do
15+ [ testGroup "List Monoids"
15− it "FirstMonoid" $ do
16+ [ testCase "FirstMonoid" $ do
16 let getFirst = destructFirstMonoid . fold . fmap constructFirstMonoid
17 let getFirst = destructFirstMonoid . fold . fmap constructFirstMonoid
17− getFirst [1 :: Int, 2, 3] `shouldBe` Just 1
18+ getFirst [1 :: Int, 2, 3] @=? Just 1
18− getFirst [] `shouldBe` (Nothing :: Maybe ())
19+ getFirst [] @=? (Nothing :: Maybe ())
19− getFirst [True, False] `shouldBe` Just True
20+ getFirst [True, False] @=? Just True
20− getFirst [True, True, False] `shouldBe` Just True
21+ getFirst [True, True, False] @=? Just True
21− getFirst [1 .. 1000] `shouldBe` Just (1 :: Int)
22+ getFirst [1 .. 1000] @=? Just (1 :: Int)
22− getFirst [100 .. 1000] `shouldBe` Just (100 :: Int)
23+ getFirst [100 .. 1000] @=? Just (100 :: Int)
23− getFirst [6, 2, 7, 398, 1984, 383, -1020] `shouldBe` Just (6 :: Int)
24+ getFirst [6, 2, 7, 398, 1984, 383, -1020] @=? Just (6 :: Int)
24− it "LastMonoid" $ do
25+ , testCase "LastMonoid" $ do
25 let getLast = destructLastMonoid . fold . fmap constructLastMonoid
26 let getLast = destructLastMonoid . fold . fmap constructLastMonoid
26− getLast [1 :: Int, 2, 3] `shouldBe` Just 3
27+ getLast [1 :: Int, 2, 3] @=? Just 3
27− getLast [] `shouldBe` (Nothing :: Maybe ())
28+ getLast [] @=? (Nothing :: Maybe ())
28− getLast [1 .. 1000] `shouldBe` Just (1000 :: Int)
29+ getLast [1 .. 1000] @=? Just (1000 :: Int)
29− getLast [100 .. 10000] `shouldBe` Just (10000 :: Int)
30+ getLast [100 .. 10000] @=? Just (10000 :: Int)
30− getLast [6, 2, 7, 398, 1984, 383, -1020, 498] `shouldBe` Just (498 :: Int)
31+ getLast [6, 2, 7, 398, 1984, 383, -1020, 498] @=? Just (498 :: Int)
31− getLast [True, False] `shouldBe` Just False
32+ getLast [True, False] @=? Just False
32− getLast [True, True, False] `shouldBe` Just False
33+ getLast [True, True, False] @=? Just False
33− getLast [True, True, False, True] `shouldBe` Just True
34+ getLast [True, True, False, True] @=? Just True
35+ ]
34− describe "Todo List" $ do
36+ , testGroup "Todo List" $
35 let createTasks :: [(String, Priority)] -> MyTaskManager
37 let createTasks :: [(String, Priority)] -> MyTaskManager
36 createTasks = foldl (\t (a, b) -> createTask a b t) emptyTaskManager
38 createTasks = foldl (\t (a, b) -> createTask a b t) emptyTaskManager
37 getPrioritySets :: MyTaskManager -> [[(Completion, String)]]
39 getPrioritySets :: MyTaskManager -> [[(Completion, String)]]
@@ -39,9 +41,10 @@ tests = do
39 fmap (sort . fmap (\(a, _, b) -> (a, b)))
41 fmap (sort . fmap (\(a, _, b) -> (a, b)))
40 . groupBy ((==) `on` (\(_, p, _) -> p))
42 . groupBy ((==) `on` (\(_, p, _) -> p))
41 . getPriorityList
43 . getPriorityList
44+ in
42− it "emptyTaskManager" $
45+ [ testCase "emptyTaskManager" $
43− getPriorityList (emptyTaskManager :: MyTaskManager) `shouldBe` []
46+ getPriorityList (emptyTaskManager :: MyTaskManager) @=? []
44− it "createTask" $ do
47+ , testCase "createTask" $ do
45 getPrioritySets
48 getPrioritySets
46 ( createTasks
49 ( createTasks
47 [ ("a", Low),
50 [ ("a", Low),
@@ -49,7 +52,7 @@ tests = do
49 ("AAAAAAAAAA", High)
52 ("AAAAAAAAAA", High)
50 ]
53 ]
51 )
54 )
52− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
55+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
53 [(NotCompleted, "aaa")],
56 [(NotCompleted, "aaa")],
54 [(NotCompleted, "a")]
57 [(NotCompleted, "a")]
55 ]
58 ]
@@ -59,7 +62,7 @@ tests = do
59 ("AAAAAAAAAA", High)
62 ("AAAAAAAAAA", High)
60 ]
63 ]
61 )
64 )
62− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
65+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
63 [(NotCompleted, "a")]
66 [(NotCompleted, "a")]
64 ]
67 ]
65 getPrioritySets
68 getPrioritySets
@@ -70,7 +73,7 @@ tests = do
70 ("oh HaiMark", Medium)
73 ("oh HaiMark", Medium)
71 ]
74 ]
72 )
75 )
73− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA")],
76+ @=? [ [(NotCompleted, "AAAAAAAAAA")],
74 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
77 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
75 [(NotCompleted, "a")]
78 [(NotCompleted, "a")]
76 ]
79 ]
@@ -83,11 +86,11 @@ tests = do
83 ("OH NO", High)
86 ("OH NO", High)
84 ]
87 ]
85 )
88 )
86− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
89+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
87 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
90 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
88 [(NotCompleted, "a")]
91 [(NotCompleted, "a")]
89 ]
92 ]
90− it "toggleTaskCompletion" $ do
93+ , testCase "toggleTaskCompletion" $ do
91 getPrioritySets
94 getPrioritySets
92 ( toggleTaskCompletion "AAAAAAAAAA" . createTasks $
95 ( toggleTaskCompletion "AAAAAAAAAA" . createTasks $
93 [ ("a", Low),
96 [ ("a", Low),
@@ -97,7 +100,7 @@ tests = do
97 ("OH NO", High)
100 ("OH NO", High)
98 ]
101 ]
99 )
102 )
100− `shouldBe` [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
103+ @=? [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
101 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
104 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
102 [(NotCompleted, "a")]
105 [(NotCompleted, "a")]
103 ]
106 ]
@@ -110,7 +113,7 @@ tests = do
110 ("OH NO", High)
113 ("OH NO", High)
111 ]
114 ]
112 )
115 )
113− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
116+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
114 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
117 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
115 [(NotCompleted, "a")]
118 [(NotCompleted, "a")]
116 ]
119 ]
@@ -126,11 +129,11 @@ tests = do
126 ("OH NO", High)
129 ("OH NO", High)
127 ]
130 ]
128 )
131 )
129− `shouldBe` [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
132+ @=? [ [(Completed, "AAAAAAAAAA"), (NotCompleted, "OH NO")],
130 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
133 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
131 [(Completed, "a")]
134 [(Completed, "a")]
132 ]
135 ]
133− it "removeTask" $ do
136+ , testCase "removeTask" $ do
134 getPrioritySets
137 getPrioritySets
135 ( removeTask "AAAAAAAAAA"
138 ( removeTask "AAAAAAAAAA"
136 . createTasks
139 . createTasks
@@ -141,7 +144,7 @@ tests = do
141 ("OH NO", High)
144 ("OH NO", High)
142 ]
145 ]
143 )
146 )
144− `shouldBe` [ [(NotCompleted, "OH NO")],
147+ @=? [ [(NotCompleted, "OH NO")],
145 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
148 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
146 [(NotCompleted, "a")]
149 [(NotCompleted, "a")]
147 ]
150 ]
@@ -155,7 +158,7 @@ tests = do
155 ("OH NO", High)
158 ("OH NO", High)
156 ]
159 ]
157 )
160 )
158− `shouldBe` [ [(NotCompleted, "OH NO")],
161+ @=? [ [(NotCompleted, "OH NO")],
159 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
162 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
160 [(NotCompleted, "a")]
163 [(NotCompleted, "a")]
161 ]
164 ]
@@ -171,10 +174,10 @@ tests = do
171 ("OH NO", High)
174 ("OH NO", High)
172 ]
175 ]
173 )
176 )
174− `shouldBe` [ [(NotCompleted, "OH NO")],
177+ @=? [ [(NotCompleted, "OH NO")],
175 [(NotCompleted, "a")]
178 [(NotCompleted, "a")]
176 ]
179 ]
177− it "modifyPriority" $ do
180+ , testCase "modifyPriority" $ do
178 getPrioritySets
181 getPrioritySets
179 ( modifyPriority "aaa" High . createTasks $
182 ( modifyPriority "aaa" High . createTasks $
180 [ ("a", Low),
183 [ ("a", Low),
@@ -184,7 +187,7 @@ tests = do
184 ("OH NO", High)
187 ("OH NO", High)
185 ]
188 ]
186 )
189 )
187− `shouldBe` [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO"), (NotCompleted, "aaa")],
190+ @=? [ [(NotCompleted, "AAAAAAAAAA"), (NotCompleted, "OH NO"), (NotCompleted, "aaa")],
188 [(NotCompleted, "oh HaiMark")],
191 [(NotCompleted, "oh HaiMark")],
189 [(NotCompleted, "a")]
192 [(NotCompleted, "a")]
190 ]
193 ]
@@ -200,7 +203,7 @@ tests = do
200 ("OH NO", High)
203 ("OH NO", High)
201 ]
204 ]
202 )
205 )
203− `shouldBe` [ [ (Completed, "a"),
206+ @=? [ [ (Completed, "a"),
204 (NotCompleted, "AAAAAAAAAA"),
207 (NotCompleted, "AAAAAAAAAA"),
205 (NotCompleted, "OH NO"),
208 (NotCompleted, "OH NO"),
206 (NotCompleted, "aaa")
209 (NotCompleted, "aaa")
@@ -220,7 +223,7 @@ tests = do
220 ("OH NO", High)
223 ("OH NO", High)
221 ]
224 ]
222 )
225 )
223− `shouldBe` [ [ (NotCompleted, "AAAAAAAAAA"),
226+ @=? [ [ (NotCompleted, "AAAAAAAAAA"),
224 (NotCompleted, "OH NO"),
227 (NotCompleted, "OH NO"),
225 (NotCompleted, "a"),
228 (NotCompleted, "a"),
226 (NotCompleted, "aaa"),
229 (NotCompleted, "aaa"),
@@ -230,7 +233,7 @@ tests = do
230 getPrioritySets
233 getPrioritySets
231 ( modifyPriority "aaa" High
234 ( modifyPriority "aaa" High
232 . modifyPriority "a" High
235 . modifyPriority "a" High
233− . modifyPriority "nit here sihji" High
236+ . modifyPriority "ntestCase here sihji" High
234 . modifyPriority "oh HaiMark" Low
237 . modifyPriority "oh HaiMark" Low
235 . modifyPriority "a" High
238 . modifyPriority "a" High
236 . modifyPriority "oh HaiMark" High
239 . modifyPriority "oh HaiMark" High
@@ -242,14 +245,14 @@ tests = do
242 ("OH NO", High)
245 ("OH NO", High)
243 ]
246 ]
244 )
247 )
245− `shouldBe` [ [ (NotCompleted, "AAAAAAAAAA"),
248+ @=? [ [ (NotCompleted, "AAAAAAAAAA"),
246 (NotCompleted, "OH NO"),
249 (NotCompleted, "OH NO"),
247 (NotCompleted, "a"),
250 (NotCompleted, "a"),
248 (NotCompleted, "aaa")
251 (NotCompleted, "aaa")
249 ],
252 ],
250 [(NotCompleted, "oh HaiMark")]
253 [(NotCompleted, "oh HaiMark")]
251 ]
254 ]
252− it "renameTask" $ do
255+ , testCase "renameTask" $ do
253 getPrioritySets
256 getPrioritySets
254 ( renameTask "AAAAAAAAAA" "henlo"
257 ( renameTask "AAAAAAAAAA" "henlo"
255 . createTasks
258 . createTasks
@@ -260,7 +263,7 @@ tests = do
260 ("OH NO", High)
263 ("OH NO", High)
261 ]
264 ]
262 )
265 )
263− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
266+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
264 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
267 [(NotCompleted, "aaa"), (NotCompleted, "oh HaiMark")],
265 [(NotCompleted, "a")]
268 [(NotCompleted, "a")]
266 ]
269 ]
@@ -276,7 +279,7 @@ tests = do
276 ("OH NO", High)
279 ("OH NO", High)
277 ]
280 ]
278 )
281 )
279− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
282+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
280 [(NotCompleted, "aaa"), (NotCompleted, "iz task")],
283 [(NotCompleted, "aaa"), (NotCompleted, "iz task")],
281 [(Completed, "a")]
284 [(Completed, "a")]
282 ]
285 ]
@@ -293,86 +296,88 @@ tests = do
293 ("OH NO", High)
296 ("OH NO", High)
294 ]
297 ]
295 )
298 )
296− `shouldBe` [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
299+ @=? [ [(NotCompleted, "OH NO"), (NotCompleted, "henlo")],
297 [(Completed, "iz task"), (NotCompleted, "aaa")],
300 [(Completed, "iz task"), (NotCompleted, "aaa")],
298 [(NotCompleted, "a")]
301 [(NotCompleted, "a")]
299 ]
302 ]
300− describe "Coffee" $ do
303+ ]
304+ , testGroup "Coffee"
301− it "HasPrice Coffee" $ do
305+ [ testCase "HasPrice Coffee" $ do
302− price (Coffee 2 [OatMilk, Cinnamon]) `shouldBe` 2 + price OatMilk + price Cinnamon
306+ price (Coffee 2 [OatMilk, Cinnamon]) @=? 2 + price OatMilk + price Cinnamon
303− price (Coffee 2 [Cinnamon, Cinnamon]) `shouldBe` 2 + price Cinnamon + price Cinnamon
307+ price (Coffee 2 [Cinnamon, Cinnamon]) @=? 2 + price Cinnamon + price Cinnamon
304− price (Coffee 2 []) `shouldBe` 2
308+ price (Coffee 2 []) @=? 2
305 price (Coffee 2 [Cinnamon, Cream, Cinnamon])
309 price (Coffee 2 [Cinnamon, Cream, Cinnamon])
306− `shouldBe` 2
310+ @=? 2
307 + price Cinnamon
311 + price Cinnamon
308 + price Cinnamon
312 + price Cinnamon
309 + price Cream
313 + price Cream
310− it "chargeCoffee" $ do
314+ , testCase "chargeCoffee" $ do
311 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 199 69)
315 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 199 69)
312− `shouldBe` Just (DebitCard 112 69)
316+ @=? Just (DebitCard 112 69)
313 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 87 69)
317 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 87 69)
314− `shouldBe` Just (DebitCard 0 69)
318+ @=? Just (DebitCard 0 69)
315 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 86 69)
319 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 86 69)
316− `shouldBe` Nothing
320+ @=? Nothing
317 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 0 69)
321 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard 0 69)
318− `shouldBe` Nothing
322+ @=? Nothing
319 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard (-2189) 69)
323 chargeCoffee (Coffee 2 [OatMilk, Cinnamon]) (DebitCard (-2189) 69)
320− `shouldBe` Nothing
324+ @=? Nothing
321 chargeCoffee (Coffee 2 [OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
325 chargeCoffee (Coffee 2 [OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
322− `shouldBe` Just (DebitCard 97 69)
326+ @=? Just (DebitCard 97 69)
323 chargeCoffee (Coffee 2 [WhiteSugar, OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
327 chargeCoffee (Coffee 2 [WhiteSugar, OatMilk, Cinnamon, WhiteSugar]) (DebitCard 199 69)
324− `shouldBe` Just (DebitCard 82 69)
328+ @=? Just (DebitCard 82 69)
325− let coffee = Coffee 2 [OatMilk, Cinnamon]
329+ , let coffee = Coffee 2 [OatMilk, Cinnamon]
326− it "payForCoffee" $ do
330+ in testCase "payForCoffee" $ do
327− payForCoffee (Customer [DebitCard 199 69] 0) coffee
331+ payForCoffee (Customer [DebitCard 199 69] 0) coffee
328− `shouldBe` Just (Card (DebitCard 112 69))
332+ @=? Just (Card (DebitCard 112 69))
329− payForCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
333+ payForCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
330− `shouldBe` Just (Card (DebitCard 112 69))
334+ @=? Just (Card (DebitCard 112 69))
331− payForCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
335+ payForCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
332− `shouldBe` Just (Card (DebitCard 112 69))
336+ @=? Just (Card (DebitCard 112 69))
333− payForCoffee (Customer [DebitCard 87 8, DebitCard 111 12, DebitCard 199 69] 0) coffee
337+ payForCoffee (Customer [DebitCard 87 8, DebitCard 111 12, DebitCard 199 69] 0) coffee
334− `shouldBe` Just (Card (DebitCard 0 8))
338+ @=? Just (Card (DebitCard 0 8))
335− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0) coffee
339+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 0) coffee
336− `shouldBe` Nothing
340+ @=? Nothing
337− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
341+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
338− `shouldBe` Just (Cash 0)
342+ @=? Just (Cash 0)
339− payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
343+ payForCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
340− `shouldBe` Nothing
344+ @=? Nothing
341− it "applyPayment" $ do
345+ , testCase "applyPayment" $ do
342 applyPayment (Customer [DebitCard 199 69] 0) (Card (DebitCard 112 69))
346 applyPayment (Customer [DebitCard 199 69] 0) (Card (DebitCard 112 69))
343− `shouldBe` Customer [DebitCard 112 69] 0
347+ @=? Customer [DebitCard 112 69] 0
344 applyPayment (Customer [DebitCard 111 12, DebitCard 199 69] 2) (Card (DebitCard 112 69))
348 applyPayment (Customer [DebitCard 111 12, DebitCard 199 69] 2) (Card (DebitCard 112 69))
345− `shouldBe` Customer [DebitCard 111 12, DebitCard 112 69] 2
349+ @=? Customer [DebitCard 111 12, DebitCard 112 69] 2
346 applyPayment (Customer [DebitCard (-12) 8, DebitCard 111 12, DebitCard 199 69] 0) (Card (DebitCard 112 69))
350 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
351+ @=? Customer [DebitCard (-12) 8, DebitCard 111 12, DebitCard 112 69] 0
348 applyPayment (Customer [DebitCard 112 8, DebitCard 111 12, DebitCard 199 69] 0) (Card (DebitCard 0 8))
352 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
353+ @=? Customer [DebitCard 0 8, DebitCard 111 12, DebitCard 199 69] 0
350 applyPayment (Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112) (Cash 0)
354 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
355+ @=? Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 0
352 applyPayment (Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112) (Card (DebitCard 0 13))
356 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
357+ @=? Customer [DebitCard 111 8, DebitCard 111 12, DebitCard 110 69] 112
358+ , let coffee = Coffee 2 [OatMilk, Cinnamon]
354− it "buyCoffee" $ do
359+ in testCase "buyCoffee" $ do
355− buyCoffee (Customer [DebitCard 199 69] 0) coffee
360+ buyCoffee (Customer [DebitCard 199 69] 0) coffee
356− `shouldBe` Just (Customer [DebitCard 112 69] 0)
361+ @=? Just (Customer [DebitCard 112 69] 0)
357− buyCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
362+ buyCoffee (Customer [DebitCard 86 12, DebitCard 199 69] 2) coffee
358− `shouldBe` Just (Customer [DebitCard 86 12, DebitCard 112 69] 2)
363+ @=? Just (Customer [DebitCard 86 12, DebitCard 112 69] 2)
359− buyCoffee (Customer [DebitCard (-12) 8, DebitCard 86 12, DebitCard 199 69] 0) coffee
364+ 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)
365+ @=? 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
366+ 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)
367+ @=? 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
368+ buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 84 69] 0) coffee
364− `shouldBe` Nothing
369+ @=? Nothing
365− buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 82 69] 87) coffee
370+ 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)
371+ @=? 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
372+ buyCoffee (Customer [DebitCard 86 8, DebitCard 86 12, DebitCard 81 69] 86) coffee
368− `shouldBe` Nothing
373+ @=? Nothing
369− it "saveTheDiabetic" $ do
374+ , testCase "saveTheDiabetic" $ do
370 saveTheDiabetic
375 saveTheDiabetic
371 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
376 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
372 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
377 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
373 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
378 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
374 ]
379 ]
375− `shouldBe` ( 150,
380+ @=? ( 150,
376 [ Coffee 0 [Cinnamon],
381 [ Coffee 0 [Cinnamon],
377 Coffee 0 [Cinnamon],
382 Coffee 0 [Cinnamon],
378 Coffee 0 [Cinnamon]
383 Coffee 0 [Cinnamon]
@@ -383,7 +388,7 @@ tests = do
383 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
388 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
384 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
389 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
385 ]
390 ]
386− `shouldBe` ( 215,
391+ @=? ( 215,
387 [ Coffee 0 [Cinnamon, SoyMilk],
392 [ Coffee 0 [Cinnamon, SoyMilk],
388 Coffee 0 [Cinnamon],
393 Coffee 0 [Cinnamon],
389 Coffee 0 [Cinnamon]
394 Coffee 0 [Cinnamon]
@@ -395,7 +400,7 @@ tests = do
395 Coffee 0 [Cinnamon],
400 Coffee 0 [Cinnamon],
396 Coffee 69 []
401 Coffee 69 []
397 ]
402 ]
398− `shouldBe` ( 0,
403+ @=? ( 0,
399 [ Coffee 0 [Cinnamon, SoyMilk],
404 [ Coffee 0 [Cinnamon, SoyMilk],
400 Coffee 0 [Cinnamon],
405 Coffee 0 [Cinnamon],
401 Coffee 0 [Cinnamon],
406 Coffee 0 [Cinnamon],
@@ -404,29 +409,31 @@ tests = do
404 )
409 )
405 saveTheDiabetic
410 saveTheDiabetic
406 []
411 []
407− `shouldBe` ( 0,
412+ @=? ( 0,
408 []
413 []
409 )
414 )
410− it "calculateSugarDanger" $ do
415+ , testCase "calculateSugarDanger" $ do
411 calculateSugarDanger
416 calculateSugarDanger
412 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
417 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
413 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
418 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
414 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
419 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon]
415 ]
420 ]
416− `shouldBe` 9
421+ @=? 9
417 calculateSugarDanger
422 calculateSugarDanger
418 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon, BrownSugar, SoyMilk],
423 [ Coffee 0 [WhiteSugar, BrownSugar, Cinnamon, BrownSugar, SoyMilk],
419 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
424 Coffee 0 [WhiteSugar, BrownSugar, WhiteSugar, WhiteSugar, Cinnamon],
420 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
425 Coffee 0 [WhiteSugar, BrownSugar, Cinnamon],
421 Coffee 0 []
426 Coffee 0 []
422 ]
427 ]
423− `shouldBe` 14
428+ @=? 14
424 calculateSugarDanger
429 calculateSugarDanger
425 [ Coffee 0 [Cinnamon, SoyMilk],
430 [ Coffee 0 [Cinnamon, SoyMilk],
426 Coffee 0 [Cinnamon],
431 Coffee 0 [Cinnamon],
427 Coffee 0 [Cinnamon]
432 Coffee 0 [Cinnamon]
428 ]
433 ]
429− `shouldBe` 0
434+ @=? 0
430 calculateSugarDanger
435 calculateSugarDanger
431 []
436 []
432− `shouldBe` 0
437+ @=? 0
438+ ]
439+ ]