fix quickcheck failure
authorJoey Hess <joeyh@joeyh.name>
Mon, 30 Dec 2019 17:54:46 +0000 (13:54 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 30 Dec 2019 17:54:46 +0000 (13:54 -0400)
prop_encode_decode_roundtrip failed on "\175" in C locale.

This may be a new problem after the switch to RawFilePath, but it
already had filtering for high chars, so changed to only test ascii
chars.

Git/Filename.hs
Utility/Format.hs

index eda4a4d9072a5119b872fe237d50c657e1b1d912..010e5bae9e72bfa8c5b0533c592fd074c7b31208 100644 (file)
@@ -46,8 +46,8 @@ prop_encode_decode_roundtrip s = s' ==
        -- "\343\200\271".
        --
        -- This property papers over the problem, by only
-       -- testing chars < 256.
-       nohigh = filter (\c -> ord c < 256)
+       -- testing ascii
+       nohigh = filter isAscii
        -- A String can contain a NUL, but toRawFilePath
        -- truncates on the NUL, which is generally fine
        -- because unix filenames cannot contain NUL.
index 3670cd717a9cebfe0f87cbba62783b229c723d15..a2470fa22874486be64943b8ee606cf315e1ac4d 100644 (file)
@@ -15,7 +15,7 @@ module Utility.Format (
 ) where
 
 import Text.Printf (printf)
-import Data.Char (isAlphaNum, isOctDigit, isHexDigit, isSpace, chr, ord)
+import Data.Char (isAlphaNum, isOctDigit, isHexDigit, isSpace, chr, ord, isAscii)
 import Data.Maybe (fromMaybe)
 import Data.Word (Word8)
 import Data.List (isPrefixOf)
@@ -176,12 +176,12 @@ encode_c' p = concatMap echar
 {- For quickcheck. 
  -
  - Encoding and then decoding roundtrips only when
- - the string does not contain high unicode, because eg, 
- - both "\12345" and "\227\128\185" are encoded to "\343\200\271".
+ - the string is ascii because eg, both "\12345" and
+ - "\227\128\185" are encoded to "\343\200\271".
  -
- - This property papers over the problem, by only testing chars < 256.
+ - This property papers over the problem, by only testing ascii.
  -}
 prop_encode_c_decode_c_roundtrip :: String -> Bool
 prop_encode_c_decode_c_roundtrip s = s' == decode_c (encode_c s')
   where
-       s' = filter (\c -> ord c < 256) s
+       s' = filter isAscii s