123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- {-# LANGUAGE CPP #-}
- {-# LANGUAGE TemplateHaskell #-}
- module Internal.Utils.FileName ( tests ) where
- import qualified Data.Text as Text
- import System.FilePath
- import Internal.Helpers
- import Agda.Utils.FileName
- rootPath :: FilePath
- #ifdef mingw32_HOST_OS
- rootPath = joinDrive "C:" [pathSeparator]
- #else
- rootPath = [pathSeparator]
- #endif
- instance Arbitrary AbsolutePath where
- arbitrary = mk . take 3 . map (take 2) <$>
- listOf (listOf1 (elements "a1"))
- where mk ps = mkAbsolute (joinPath $ rootPath : ps)
- instance CoArbitrary AbsolutePath where
- coarbitrary (AbsolutePath t) = coarbitrary (Text.unpack t)
- prop_absolutePathInvariant :: AbsolutePath -> Bool
- prop_absolutePathInvariant x =
- isAbsolute f &&
- isValid f &&
- f == normalise f &&
- f == dropTrailingPathSeparator f
- where f = filePath x
- prop_mkAbsolute :: FilePath -> Property
- prop_mkAbsolute f =
- let path = rootPath ++ f
- in isValid path ==> prop_absolutePathInvariant $ mkAbsolute $ path
- return []
- tests :: TestTree
- tests = testProperties "Internal.Utils.FileName" $allProperties
|