Skip to content

Commit

Permalink
Work around when getFileSystemEncoding is ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Sep 11, 2021
1 parent 25ad0e0 commit d3d73db
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/Properties/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#ifndef BYTESTRING_LAZY
module Properties.ByteString (tests) where
import qualified Data.ByteString as B
import GHC.IO.Encoding
#else
module Properties.ByteStringLazy (tests) where
import qualified Data.ByteString.Lazy as B
Expand Down Expand Up @@ -83,10 +84,16 @@ tests =
\x -> ioProperty $ do
r <- B.toFilePath x >>= B.fromFilePath
pure (r === x)
, testProperty "fromFilePath >>= toFilePath" $
\x -> ioProperty $ do
r <- B.fromFilePath x >>= B.toFilePath
pure (r === x)
, testProperty "fromFilePath >>= toFilePath" $ ioProperty $ do
let prop x = ioProperty $ do
r <- B.fromFilePath x >>= B.toFilePath
pure (r === x)
-- Normally getFileSystemEncoding returns one of Unicode encodings,
-- but if it is ASCII, we should not generate Unicode filenames.
enc <- getFileSystemEncoding
pure $ case textEncodingName enc of
"ASCII" -> property (prop . getASCIIString)
_ -> property prop
#endif
#endif

Expand Down

0 comments on commit d3d73db

Please sign in to comment.