on master help sign in
Add tests for nested parallel/serial compositions
24fa86fHarendra Kumar
test/Main.hs+28
@@ -87,6 +87,31 @@ main = hspec $ do
87 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
87 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
88 ])
88 ])
89
89
90+ describe "Nested parallel and serial compositions" $ do
91+ it "Nest <|>, <>, <|> (1)" $
92+ let t = timed
93+ in toList (
94+ ((t 8 <|> t 4) <> (t 2 <|> t 0))
95+ <|> ((t 8 <|> t 4) <> (t 2 <|> t 0)))
96+ `shouldReturn` ([4,4,8,8,0,0,2,2])
97+ it "Nest <|>, <>, <|> (2)" $
98+ let t = timed
99+ in toList (
100+ ((t 4 <|> t 8) <> (t 0 <|> t 2))
101+ <|> ((t 4 <|> t 8) <> (t 0 <|> t 2)))
102+ `shouldReturn` ([4,4,8,8,0,0,2,2])
103+ it "Nest <|>, <=>, <|> (1)" $
104+ let t = timed
105+ in toList (
106+ ((t 8 <|> t 4) <=> (t 2 <|> t 0))
107+ <|> ((t 8 <|> t 4) <=> (t 2 <|> t 0)))
108+ `shouldReturn` ([4,4,0,0,8,8,2,2])
109+ it "Nest <|>, <=>, <|> (2)" $
110+ let t = timed
111+ in toList (
112+ ((t 4 <|> t 8) <=> (t 0 <|> t 2))
113+ <|> ((t 4 <|> t 8) <=> (t 0 <|> t 2)))
114+ `shouldReturn` ([4,4,0,0,8,8,2,2])
90
115
91 ---------------------------------------------------------------------------
116 ---------------------------------------------------------------------------
92 -- Monoidal composition recursion loops
117 -- Monoidal composition recursion loops
@@ -121,6 +146,9 @@ main = hspec $ do
121
146
122 describe "Transformation" $ transformOps (<>)
147 describe "Transformation" $ transformOps (<>)
123
148
149+timed :: Int -> AsyncT IO Int
150+timed x = liftIO (threadDelay (x * 100000)) >> return x
151+
124thenBind :: Spec
152thenBind :: Spec
125thenBind = do
153thenBind = do
126 it "Simple runAsyncly and 'then' with IO" $
154 it "Simple runAsyncly and 'then' with IO" $