on master help sign in
Add tests for nested parallel/serial compositions
commit24fa86feb9e544dc63d9987689a1aed5ed572898 authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 19 Sep 2017, 22:33 (9 years ago) parent55356f6
1 file changed+28
test/Main.hs+28
test/Main.hs+28
@@ -87,6 +87,31 @@ main = hspec $ do
8787 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
8888 ])
8989
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])
90115
91116 ---------------------------------------------------------------------------
92117 -- Monoidal composition recursion loops
@@ -121,6 +146,9 @@ main = hspec $ do
121146
122147 describe "Transformation" $ transformOps (<>)
123148
149+timed :: Int -> AsyncT IO Int
150+timed x = liftIO (threadDelay (x * 100000)) >> return x
151+
124152thenBind :: Spec
125153thenBind = do
126154 it "Simple runAsyncly and 'then' with IO" $