on master help sign in
Add test case for hierarchical alternative composition
commitab912679674338e2bbb3b65593009bfa9bbf91c8 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 25 Aug 2017, 23:38 (9 years ago) parent5181c0d
1 file changed+4
test/Main.hs+4
test/Main.hs+4
@@ -44,6 +44,10 @@ main = hspec $ do
4444 ((toList $ (((return 0 <|> return 1) <|> return 2) <|> return 3)) >>= return . sort) `shouldReturn` ([0, 1, 2, 3] :: [Int])
4545 it "Alternative composition - right associated" $
4646 ((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])
4751 it "Alternative composition (right fold) with bind" $
4852 (toList (for [1..10 :: Int] $ \x -> return x >>= return . id) >>= return . sort) `shouldReturn` ([1..10] :: [Int])
4953 it "Alternative composition (left fold) with bind" $