@@ -13,7 +13,8 @@ import Data.String.NonEmpty (NonEmptyString)
13
13
import Data.String.NonEmpty as NES
14
14
import Data.Symbol (SProxy (..))
15
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 , (<..>), (<.>), (</>))
16
+ import Pathy (class IsDirOrFile , class IsRelOrAbs , Abs , Dir , File , Name (..), Path , Rel , alterExtension , currentDir , debugPrintPath , dir , extension , file , file' , in' , joinName , move , moveFile , parentOf , parseAbsDir , parseAbsFile , parseRelDir , parseRelFile , peel , posixParser , posixPrinter , printPath , relativeTo , rename , rootDir , sandbox , sandboxAny , splitName , unsandbox , windowsPrinter , (<..>), (<.>), (</>))
17
+ import Pathy.Gen (genName )
17
18
import Pathy.Gen as PG
18
19
import Pathy.Name (reflectName )
19
20
import Test.QuickCheck ((===))
@@ -101,6 +102,34 @@ checkPeelIn gen = do
101
102
p <- gen
102
103
pure $ p === maybe p (\(Tuple r n) -> r </> in' n) (peel p)
103
104
105
+ checkMove
106
+ :: forall b a
107
+ . IsRelOrAbs a
108
+ => IsDirOrFile b
109
+ => Gen.Gen (Path a Dir )
110
+ -> Gen.Gen (Name b )
111
+ -> Gen.Gen (Path Rel Dir )
112
+ -> Gen.Gen QC.Result
113
+ checkMove genRoot genName genTarget = do
114
+ h <- genRoot
115
+ n <- genName
116
+ target <- genTarget
117
+ pure $ move (h </> in' n) target === Just (h </> target </> in' n)
118
+
119
+ checkMoveFile
120
+ :: forall a b
121
+ . IsRelOrAbs a
122
+ => Gen.Gen (Path a Dir )
123
+ -> Gen.Gen (Name File )
124
+ -> Gen.Gen (Path Rel Dir )
125
+ -> Gen.Gen QC.Result
126
+ checkMoveFile genRoot genName genTarget = do
127
+ h <- genRoot
128
+ n <- genName
129
+ target <- genTarget
130
+ pure $ moveFile (h </> file' n) target === (h </> target </> file' n)
131
+
132
+
104
133
checkRelative :: forall b . IsDirOrFile b => Gen.Gen (Path Abs b ) -> Gen.Gen QC.Result
105
134
checkRelative gen = do
106
135
p1 <- gen
@@ -124,6 +153,12 @@ main = do
124
153
info " checking `parse <<< print` for `AbsFile`" *> QC .quickCheck parsePrintAbsFilePath
125
154
info " checking `parse <<< print` for `RelDir`" *> QC .quickCheck parsePrintRelDirPath
126
155
info " checking `parse <<< print` for `RelFile`" *> QC .quickCheck parsePrintRelFilePath
156
+ info " checking `move (absPath </> file' n) target == Just (absPath </> target </> file' n)`" *> QC .quickCheck (checkMove PG .genAbsDirPath PG .genFileName PG .genRelDirPath)
157
+ info " checking `move (relPath </> file' n) target == Just (relPath </> target </> file' n)`" *> QC .quickCheck (checkMove PG .genRelDirPath PG .genFileName PG .genRelDirPath)
158
+ info " checking `move (absPath </> dir' n) target == Just (absPath </> target </> dir' n)`" *> QC .quickCheck (checkMove PG .genAbsDirPath PG .genDirName PG .genRelDirPath)
159
+ info " checking `move (relPath </> dir' n) target == Just (relPath </> target </> dir' n)`" *> QC .quickCheck (checkMove PG .genRelDirPath PG .genDirName PG .genRelDirPath)
160
+ info " checking `moveFile (absPath </> file' n) target == absPath </> target </> file' n`" *> QC .quickCheck (checkMoveFile PG .genAbsDirPath genName PG .genRelDirPath)
161
+ info " checking `moveFile (relPath </> file' n) target == relPath </> target </> file' n`" *> QC .quickCheck (checkMoveFile PG .genRelDirPath genName PG .genRelDirPath)
127
162
info " checking `relativeTo` for `AbsDir`" *> QC .quickCheck (checkRelative PG .genAbsDirPath)
128
163
info " checking `relativeTo` for `AbsFile`" *> QC .quickCheck (checkRelative PG .genAbsFilePath)
129
164
info " checking `p === maybe p (\\ (Tuple r n) -> r </> in' n) (peel p)` for `AbsDir`" *> QC .quickCheck (checkPeelIn PG .genAbsDirPath)
0 commit comments