{- This file is part of razom-text-util. - - Written in 2015 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - - The author(s) have dedicated all copyright and related and neighboring - rights to this software to the public domain worldwide. This software is - distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along - with this software. If not, see - . -} import Control.Monad (unless) import Data.Smaoin (realnum) import System.Exit import Test.QuickCheck import Test.QuickCheck.Test import Text.Printf import Text.Razom import Text.Regex.Applicative (match) main :: IO () main = do results <- mapM (\ (name ,action) -> printf "%-25s: " name >> action) tests unless (all isSuccess results) exitFailure prop_digitsToNum :: Bool prop_digitsToNum = digitsToNum 2 [1, 0, 1, 1, 0, 1] == 45 && digitsToNum 16 [15, 15] == 255 prop_fromDigits :: Bool prop_fromDigits = fromDigits [1, 4, 2] [8, 5, 7] == realnum 142857 (-3) prop_uid :: Bool prop_uid = match uid "<12<34\\>46\\\\7>" == Just "12<34>46\\7" prop_generator :: Bool prop_generator = match generator "<%>" == Just "" && match generator "<%label>" == Just "label" prop_escapeUid :: Bool prop_escapeUid = escapeUid "1>2\\3" == "1\\>2\\\\3" prop_unescapeUid :: Bool prop_unescapeUid = unescapeUid "1\\>2\\\\3" == "1>2\\3" prop_literal :: Bool prop_literal = match literal "{{1\\}2\\\\3}}" == Just "1\\}2\\\\3" tests :: [(String, IO Result)] tests = [ ("digitsToNum", quickCheckResult prop_digitsToNum) , ("fromDigits", quickCheckResult prop_fromDigits) , ("uid", quickCheckResult prop_uid) , ("generator", quickCheckResult prop_generator) , ("escapeUid", quickCheckResult prop_escapeUid) , ("unescapeUid", quickCheckResult prop_unescapeUid) , ("literal", quickCheckResult prop_literal) ]