another quickcheck

This commit is contained in:
Joey Hess 2012-12-20 00:02:33 -04:00
parent df1540787f
commit df90a2acd5
2 changed files with 15 additions and 1 deletions

View file

@ -11,8 +11,11 @@ module Logs.Remote (
configSet, configSet,
keyValToConfig, keyValToConfig,
configToKeyVal, configToKeyVal,
showConfig,
parseConfig,
prop_idempotent_configEscape prop_idempotent_configEscape,
prop_parse_show_Config,
) where ) where
import qualified Data.Map as M import qualified Data.Map as M
@ -86,3 +89,12 @@ configUnEscape = unescape
{- for quickcheck -} {- for quickcheck -}
prop_idempotent_configEscape :: String -> Bool prop_idempotent_configEscape :: String -> Bool
prop_idempotent_configEscape s = s == (configUnEscape . configEscape) s prop_idempotent_configEscape s = s == (configUnEscape . configEscape) s
prop_parse_show_Config :: RemoteConfig -> Bool
prop_parse_show_Config c
-- whitespace and '=' are not supported in keys
| any (\k -> any isSpace k || any (== '=') k) (M.keys c) = True
| otherwise = parseConfig (showConfig c) ~~ Just c
where
normalize v = sort . M.toList <$> v
a ~~ b = normalize a == normalize b

View file

@ -10,6 +10,7 @@
import Test.HUnit import Test.HUnit
import Test.HUnit.Tools import Test.HUnit.Tools
import Test.QuickCheck import Test.QuickCheck
import Test.QuickCheck.Instances ()
import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Directory (changeWorkingDirectory)
import System.Posix.Files import System.Posix.Files
@ -107,6 +108,7 @@ quickcheck = TestLabel "quickcheck" $ TestList
, qctest "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape , qctest "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape
, qctest "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword , qctest "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword
, qctest "prop_idempotent_configEscape" Logs.Remote.prop_idempotent_configEscape , qctest "prop_idempotent_configEscape" Logs.Remote.prop_idempotent_configEscape
, qctest "prop_parse_show_Config" Logs.Remote.prop_parse_show_Config
, qctest "prop_parentDir_basics" Utility.Path.prop_parentDir_basics , qctest "prop_parentDir_basics" Utility.Path.prop_parentDir_basics
, qctest "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics , qctest "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics
, qctest "prop_relPathDirToFile_regressionTest" Utility.Path.prop_relPathDirToFile_regressionTest , qctest "prop_relPathDirToFile_regressionTest" Utility.Path.prop_relPathDirToFile_regressionTest