on master help sign in
Move a test code block
2cc5c12Harendra Kumar
test/Main.hs+4−4
@@ -44,15 +44,15 @@ main = hspec $ do
44 ((toList $ (((return 0 <|> return 1) <|> return 2) <|> return 3)) >>= return . sort) `shouldReturn` ([0, 1, 2, 3] :: [Int])
44 ((toList $ (((return 0 <|> return 1) <|> return 2) <|> return 3)) >>= return . sort) `shouldReturn` ([0, 1, 2, 3] :: [Int])
45 it "Alternative composition - right associated" $
45 it "Alternative composition - right associated" $
46 ((toList $ (return 0 <|> (return 1 <|> (return 2 <|> return 3)))) >>= return . sort) `shouldReturn` ([0, 1, 2, 3] :: [Int])
46 ((toList $ (return 0 <|> (return 1 <|> (return 2 <|> return 3)))) >>= return . sort) `shouldReturn` ([0, 1, 2, 3] :: [Int])
47− it "Alternative composition - hierarchical" $
48− ((toList $ (((return 0 <|> return 1) <|> (return 2 <|> return 3))
49− <|> ((return 4 <|> return 5) <|> (return 6 <|> return 7)))
50− ) >>= return . sort) `shouldReturn` ([0..7] :: [Int])
51 it "Alternative composition (right fold) with bind" $
47 it "Alternative composition (right fold) with bind" $
52 (toList (for [1..10 :: Int] $ \x -> return x >>= return . id) >>= return . sort) `shouldReturn` ([1..10] :: [Int])
48 (toList (for [1..10 :: Int] $ \x -> return x >>= return . id) >>= return . sort) `shouldReturn` ([1..10] :: [Int])
53 it "Alternative composition (left fold) with bind" $
49 it "Alternative composition (left fold) with bind" $
54 let forL xs f = foldl (<|>) empty $ map f xs
50 let forL xs f = foldl (<|>) empty $ map f xs
55 in (toList (forL [1..10 :: Int] $ \x -> return x >>= return . id) >>= return . sort) `shouldReturn` ([1..10] :: [Int])
51 in (toList (forL [1..10 :: Int] $ \x -> return x >>= return . id) >>= return . sort) `shouldReturn` ([1..10] :: [Int])
52+ it "Alternative composition - hierarchical" $
53+ ((toList $ (((return 0 <|> return 1) <|> (return 2 <|> return 3))
54+ <|> ((return 4 <|> return 5) <|> (return 6 <|> return 7)))
55+ ) >>= return . sort) `shouldReturn` ([0..7] :: [Int])
56 {-
56 {-
57 it "Alternative composition of async and sync tasks" $
57 it "Alternative composition of async and sync tasks" $
58 ((wait (threads 0 ((async (return 0) <|> return 1)))) >>= return . sort)
58 ((wait (threads 0 ((async (return 0) <|> return 1)))) >>= return . sort)