on master help sign in
Merge pull request #1 from psibi/fix-test
5df19ceHarendra Kumar
test/Main.hs+35−11
@@ -58,10 +58,35 @@ main = hspec $ do
58 ---------------------------------------------------------------------------
58 ---------------------------------------------------------------------------
59
59
60 -- TBD need more such combinations to be tested.
60 -- TBD need more such combinations to be tested.
61− describe "<> and <>" $ composeAndComposeSimple (<>) (<>) [1..9]
61+ describe "<> and <>" $ composeAndComposeSimple (<>) (<>) (cycle [[1 .. 9]])
62+
62− describe "<> and <=>" $ composeAndComposeSimple (<>) (<=>) [1..9]
63+ describe "<> and <=>" $ composeAndComposeSimple
64+ (<>)
65+ (<=>)
66+ ([ [1 .. 9]
67+ , [1 .. 9]
68+ , [1, 3, 2, 4, 6, 5, 7, 9, 8]
69+ , [1, 3, 2, 4, 6, 5, 7, 9, 8]
70+ ])
71+
63− describe "<=> and <=>" $ composeAndComposeSimple (<=>) (<=>) [1,4,7,2,5,8,3,6,9]
72+ describe "<=> and <=>" $ composeAndComposeSimple
73+ (<=>)
74+ (<=>)
75+ ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
76+ , [1, 7, 4, 8, 2, 9, 5, 3, 6]
77+ , [1, 4, 3, 7, 2, 6, 9, 5, 8]
78+ , [1, 7, 4, 9, 3, 8, 6, 2, 5]
79+ ])
80+
64− describe "<=> and <>" $ composeAndComposeSimple (<=>) (<>) [1,4,7,2,5,8,3,6,9]
81+ describe "<=> and <>" $ composeAndComposeSimple
82+ (<=>)
83+ (<>)
84+ ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
85+ , [1, 7, 4, 8, 2, 9, 5, 3, 6]
86+ , [1, 4, 2, 7, 3, 5, 8, 6, 9]
87+ , [1, 7, 4, 8, 2, 9, 5, 3, 6]
88+ ])
89+
65
90
66 ---------------------------------------------------------------------------
91 ---------------------------------------------------------------------------
67 -- Monoidal composition recursion loops
92 -- Monoidal composition recursion loops
@@ -167,30 +192,29 @@ compose f srt = do
167composeAndComposeSimple
192composeAndComposeSimple
168 :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
193 :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
169 -> (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
194 -> (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
170− -> [Int]
195+ -> [[Int]]
171 -> Spec
196 -> Spec
172composeAndComposeSimple f g answer = do
197composeAndComposeSimple f g answer = do
173 it "Compose right associated outer expr, right folded inner" $
198 it "Compose right associated outer expr, right folded inner" $
174 let fold = foldMapWith g return
199 let fold = foldMapWith g return
175 in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
200 in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
176− `shouldReturn` answer
201+ `shouldReturn` (answer !! 0)
177
202
178− {-
179 it "Compose left associated outer expr, right folded inner" $
203 it "Compose left associated outer expr, right folded inner" $
180 let fold = foldMapWith g return
204 let fold = foldMapWith g return
181 in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
205 in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
182− `shouldReturn` answer
206+ `shouldReturn` (answer !! 1)
183
207
184 it "Compose right associated outer expr, left folded inner" $
208 it "Compose right associated outer expr, left folded inner" $
185 let fold xs = foldl g empty $ map return xs
209 let fold xs = foldl g empty $ map return xs
186 in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
210 in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
187− `shouldReturn` answer
211+ `shouldReturn` (answer !! 2)
188
212
189 it "Compose left associated outer expr, left folded inner" $
213 it "Compose left associated outer expr, left folded inner" $
190 let fold xs = foldl g empty $ map return xs
214 let fold xs = foldl g empty $ map return xs
191 in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
215 in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
192− `shouldReturn` answer
216+ `shouldReturn` (answer !! 3)
193− -}
217+
194
218
195loops
219loops
196 :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
220 :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)