You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
516 B
26 lines
516 B
module Main where |
|
|
|
import qualified Data.Map as M |
|
import Morse |
|
import Test.QuickCheck |
|
|
|
allowedChars :: [Char] |
|
allowedChars = M.keys letterToMorse |
|
|
|
allowedMorse :: [Morse] |
|
allowedMorse = M.elems letterToMorse |
|
|
|
charGen :: Gen Char |
|
charGen = elements allowedChars |
|
|
|
morseGen :: Gen Morse |
|
morseGen = elements allowedMorse |
|
|
|
prop_thereAndBackAgain :: Property |
|
prop_thereAndBackAgain = |
|
forAll charGen |
|
(\c -> ((charToMorse c) |
|
>>= morseToChar ) == Just c) |
|
|
|
main :: IO () |
|
main = quickCheck prop_thereAndBackAgain
|
|
|