summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-02 16:49:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-02 16:49:35 -0400
commitd93a37289406fbeb0cedf05f1c8009f68cdb2570 (patch)
tree91743836be32ceceaa361b5fd1640c12c480ab41 /GitRepo.hs
parentc7b0f60fba9f53ed97c43f3ad9a48e7698b97760 (diff)
add a stupid test harness
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index d9dd086f2..7d5291ff1 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -40,7 +40,7 @@ module GitRepo (
decodeGitFile,
encodeGitFile,
- prop_idempotent_encode
+ prop_idempotent_deencode
) where
import Monad (unless)
@@ -351,10 +351,10 @@ decodeGitFile f@(c:s)
pair = span (/= e) v
beginning = fst pair
rest = snd pair
- isescape c = c == e
+ isescape x = x == e
-- \NNN is an octal encoded character
- decode (e:n1:n2:n3:rest)
- | isescape e && alloctal = (fromoctal, rest)
+ decode (x:n1:n2:n3:rest)
+ | isescape x && alloctal = (fromoctal, rest)
where
alloctal = isOctDigit n1 &&
isOctDigit n2 &&
@@ -362,8 +362,8 @@ decodeGitFile f@(c:s)
fromoctal = [chr $ readoctal (n1:n2:n3:[])]
readoctal o = read $ "0o" ++ o :: Int
-- \C is used for a few special characters
- decode (e:nc:rest)
- | isescape e = ([echar nc], rest)
+ decode (x:nc:rest)
+ | isescape x = ([echar nc], rest)
where
echar 'a' = '\a'
echar 'b' = '\b'
@@ -372,7 +372,7 @@ decodeGitFile f@(c:s)
echar 'r' = '\r'
echar 't' = '\t'
echar 'v' = '\v'
- echar x = x
+ echar a = a
decode n = ("", n)
{- Should not need to use this, except for testing decodeGitFile. -}
@@ -404,8 +404,8 @@ encodeGitFile s = (foldl (++) "\"" (map echar s)) ++ "\""
{- for quickcheck -}
-prop_idempotent_encode :: String -> Bool
-prop_idempotent_encode s = s == (decodeGitFile $ encodeGitFile s)
+prop_idempotent_deencode :: String -> Bool
+prop_idempotent_deencode s = s == (decodeGitFile $ encodeGitFile s)
{- Finds the current git repository, which may be in a parent directory. -}
repoFromCwd :: IO Repo