1import Control.Applicative ((<*>))
2import Data.Functor ((<$>))
4import Data.ByteString (ByteString)
5import qualified Data.ByteString.Char8 as BC8
14instance Arbitrary UUID where
16 fromWords <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
18-- Testing what we do in the codebase
19fromASCIIBytes_naive :: ByteString -> Maybe UUID
20fromASCIIBytes_naive = fromString . BC8.unpack
22toASCIIBytes_naive :: UUID -> ByteString
23toASCIIBytes_naive = BC8.pack . toString
25randomUUIDs :: IO [UUID]
26randomUUIDs = sample' arbitrary
28randomCorrect :: IO [String]
29randomCorrect = map toString <$> randomUUIDs
31randomSlightlyWrong :: IO [String]
32randomSlightlyWrong = mapM screw =<< randomCorrect
35 ix <- randomRIO (0, length s - 1)
36 return (take ix s ++ "x" ++ drop (ix + 1) s)
38randomVeryWrong :: IO [String]
39randomVeryWrong = sample' arbitrary
44 correct <- randomCorrect
45 let correctBytes = map BC8.pack correct
46 slightlyWrong <- randomSlightlyWrong
47 let slightlyWrongBytes = map BC8.pack slightlyWrong
48 veryWrong <- randomVeryWrong
49 let veryWrongBytes = map BC8.pack veryWrong
55 [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) correctBytes)
56 , bench "fromString" (nf (map fromString) correct)
57 , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) correctBytes)
61 [ bgroup "slightly wrong"
62 [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) slightlyWrongBytes)
63 , bench "fromString" (nf (map fromString) slightlyWrong)
64 , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) slightlyWrongBytes)
69 [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) veryWrongBytes)
70 , bench "fromString" (nf (map fromString) veryWrong)
71 , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) veryWrongBytes)
77 [ bench "toASCIIBytes" (nf (map toASCIIBytes) uuids)
78 , bench "toString" (nf (map toString) uuids)
79 , bench "toASCIIBytes_naive" (nf (map toASCIIBytes_naive) uuids)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list