Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Combinators where
- import Control.Monad (forM_)
- import Test.Hspec
- import Test.QuickCheck
- import Text.RE.PCRE
- alphabetical :: Gen Char
- alphabetical = elements $ ['A'..'Z'] ++ ['a'..'z']
- lower :: Gen Char
- lower = elements ['a'..'z']
- mkSpecificTests :: [String] -> [String] -> RE -> Spec
- mkSpecificTests positives negatives myRegex =
- describe "specific tests" $ do
- describe "positives" $ do
- forM_ positives $ \str -> do
- it ("matches " ++ str) $
- (str ?=~ myRegex) `shouldSatisfy` matched
- describe "negatives" $ do
- forM_ negatives $ \str -> do
- it ("fails " ++ str) $
- (str ?=~ myRegex) `shouldNotSatisfy` matched
- repeatedWord :: Gen String
- repeatedWord = do
- w <- word
- n <- arbitrary `suchThat` (>= 1) :: Gen Int
- return $ foldl (\accumulator _ -> accumulator ++ " " ++ w) w [1 .. n]
- word :: Gen String
- word = listOf1 alphabetical
- -- wordChar :: Gen Char
- -- wordChar = elements $ ['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9'] ++ "_"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement