thought of another way to break prop_idempotent_key_decode

This commit is contained in:
Joey Hess 2014-03-05 00:23:22 -04:00
parent e8ab82390e
commit 7f9a0c153b

View file

@ -97,4 +97,12 @@ prop_idempotent_key_encode :: Key -> Bool
prop_idempotent_key_encode k = Just k == (file2key . key2file) k
prop_idempotent_key_decode :: FilePath -> Bool
prop_idempotent_key_decode f = maybe True (\k -> key2file k == f) (file2key f)
prop_idempotent_key_decode f
| normalfieldorder = maybe True (\k -> key2file k == f) (file2key f)
| otherwise = True
where
-- file2key will accept the fields in any order, so don't
-- try the test unless the fields are in the normal order
normalfieldorder = fields `isPrefixOf` "sm"
fields = map (f !!) $ filter (< length f) $ map succ $
elemIndices fieldSep f