hnix-store/hnix-store-core/tests/StorePath.hs
Anton Latukha 792c76b0af
Core, Remote: handcrafted code clean-up (#134)
`brittany` was used.

Then all changes passed through manual supervision.

Then handcrafted code cleanup was done.

All changes are pure lambda code refactoring,
there should be no changes to the functionality.
2021-02-03 12:44:58 +02:00

32 lines
1.1 KiB
Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module StorePath where
import qualified Data.Attoparsec.Text.Lazy
import Test.Tasty.QuickCheck
import System.Nix.StorePath
import Arbitrary
-- | Test that Nix(OS) like paths roundtrip
prop_storePathRoundtrip :: NixLike -> NixLike -> Property
prop_storePathRoundtrip (_ :: NixLike) = \(NixLike x) ->
(parsePath "/nix/store" $ storePathToRawFilePath x) === Right x
-- | Test that any `StorePath` roundtrips
prop_storePathRoundtrip' :: StorePath -> Property
prop_storePathRoundtrip' x =
(parsePath (storePathRoot x) $ storePathToRawFilePath x) === Right x
prop_storePathRoundtripParser :: NixLike -> NixLike -> Property
prop_storePathRoundtripParser (_ :: NixLike) = \(NixLike x) ->
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
prop_storePathRoundtripParser' :: StorePath -> Property
prop_storePathRoundtripParser' x =
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x