@@ -1,9 +1,10 @@
11module Main (main) where
22
3+import Control.Applicative ((<|>))
34import Control.Exception (SomeException(..), try)
45import Data.Word (Word8, Word32, Word64)
56import Streamly.Test.Common (listEquals, checkListEqual, chooseInt, equals)
6−import Test.Hspec (Spec, hspec, describe)
7+import Test.Hspec (Spec, hspec, describe, Expectation, it, shouldReturn)
78import Test.Hspec.QuickCheck
89import Test.QuickCheck
910 (arbitrary, forAll, elements, Property,
@@ -586,6 +587,20 @@ sequence =
586587 (S.fromList $ concat ins)
587588 listEquals (==) outs ins
588589
590+altEOF1 :: Expectation
591+altEOF1 =
592+ S.parseD
593+ (P.satisfy (> 0) <|> return 66)
594+ (S.fromList ([]::[Int]))
595+ `shouldReturn` 66
596+
597+altEOF2 :: Expectation
598+altEOF2 =
599+ S.parseD
600+ ((P.takeEQ 2 FL.toList) <|> (P.takeEQ 1 FL.toList))
601+ (S.fromList ([51]::[Int]))
602+ `shouldReturn` [51]
603+
589604monad :: Property
590605monad =
591606 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
@@ -735,6 +750,8 @@ main =
735750
736751 describe "Instances" $ do
737752 prop "applicative" applicative
753+ it "Alternative: end of input 1" altEOF1
754+ it "Alternative: end of input 2" altEOF2
738755 prop "monad" monad
739756 prop "sequence" sequence
740757