@@ -5,14 +5,15 @@ import Prelude
55import Control.Monad.Eff (Eff )
66import Control.Monad.Eff.Console (CONSOLE , info )
77import Control.Monad.Eff.Exception (EXCEPTION , throw )
8- import Data.Maybe (Maybe (..))
8+ import Data.Maybe (Maybe (..), maybe )
99import Data.Newtype (un )
1010import Data.NonEmpty ((:|))
1111import Data.String as Str
1212import Data.String.NonEmpty (NonEmptyString )
1313import Data.String.NonEmpty as NES
1414import Data.Symbol (SProxy (..))
15- import Pathy (class IsDirOrFile , class IsRelOrAbs , Abs , Dir , Name (..), Path , Rel , alterExtension , currentDir , debugPrintPath , dir , extension , file , joinName , parentOf , parseAbsDir , parseAbsFile , parseRelDir , parseRelFile , posixParser , posixPrinter , printPath , relativeTo , rename , rootDir , sandbox , sandboxAny , splitName , unsandbox , windowsPrinter , (<..>), (<.>), (</>))
15+ import Data.Tuple (Tuple (..))
16+ import Pathy (class IsDirOrFile , class IsRelOrAbs , Abs , Dir , Name (..), Path , Rel , alterExtension , currentDir , debugPrintPath , dir , extension , file , in' , joinName , parentOf , parseAbsDir , parseAbsFile , parseRelDir , parseRelFile , peel , posixParser , posixPrinter , printPath , relativeTo , rename , rootDir , sandbox , sandboxAny , splitName , unsandbox , windowsPrinter , (<..>), (<.>), (</>))
1617import Pathy.Gen as PG
1718import Pathy.Name (reflectName )
1819import Test.QuickCheck ((===))
@@ -95,6 +96,11 @@ checkJoinSplitNameId = do
9596 n <- genAmbigiousName
9697 pure $ joinName (splitName n) === id n
9798
99+ checkPeelIn :: forall b . IsDirOrFile b => Gen.Gen (Path Abs b ) -> Gen.Gen QC.Result
100+ checkPeelIn gen = do
101+ p <- gen
102+ pure $ p === maybe p (\(Tuple r n) -> r </> in' n) (peel p)
103+
98104checkRelative :: forall b . IsDirOrFile b => Gen.Gen (Path Abs b ) -> Gen.Gen QC.Result
99105checkRelative gen = do
100106 p1 <- gen
@@ -120,6 +126,8 @@ main = do
120126 info " checking `parse <<< print` for `RelFile`" *> QC .quickCheck parsePrintRelFilePath
121127 info " checking `relativeTo` for `AbsDir`" *> QC .quickCheck (checkRelative PG .genAbsDirPath)
122128 info " checking `relativeTo` for `AbsFile`" *> QC .quickCheck (checkRelative PG .genAbsFilePath)
129+ info " checking `p === maybe p (\\ (Tuple r n) -> r </> in' n) (peel p)` for `AbsDir`" *> QC .quickCheck (checkPeelIn PG .genAbsDirPath)
130+ info " checking `p === maybe p (\\ (Tuple r n) -> r </> in' n) (peel p)` for `AbsFile`" *> QC .quickCheck (checkPeelIn PG .genAbsFilePath)
123131 info " checking `joinName <<< splitName === id`" *> QC .quickCheck checkJoinSplitNameId
124132 info " checking `alterExtension id === id`" *> QC .quickCheck checkAlterExtensionId
125133
0 commit comments