path-pieces 0.1.1 → 0.1.2
raw patch · 3 files changed
+78/−8 lines, 3 filesdep ~QuickCheckdep ~hspecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, hspec
API changes (from Hackage documentation)
Files
- Web/PathPieces.hs +3/−3
- path-pieces.cabal +6/−5
- test/main.hs +69/−0
Web/PathPieces.hs view
@@ -20,15 +20,15 @@ toPathPiece :: s -> S.Text instance PathPiece String where- fromPathPiece s = if S.null s then Nothing else Just (S.unpack s)+ fromPathPiece = Just . S.unpack toPathPiece = S.pack instance PathPiece S.Text where- fromPathPiece s = if S.null s then Nothing else Just s+ fromPathPiece = Just toPathPiece = id instance PathPiece L.Text where- fromPathPiece s = if S.null s then Nothing else Just (L.fromChunks [s])+ fromPathPiece = Just . L.fromChunks . return toPathPiece = S.concat . L.toChunks instance PathPiece Integer where
path-pieces.cabal view
@@ -1,5 +1,5 @@ name: path-pieces-version: 0.1.1+version: 0.1.2 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -9,7 +9,8 @@ stability: unstable cabal-version: >= 1.8 build-type: Simple-homepage: http://github.com/snoyberg/path-pieces+extra-source-files:+ test/main.hs library build-depends: base >= 4 && < 5@@ -24,13 +25,13 @@ hs-source-dirs: test ghc-options: -Wall build-depends: HUnit- , hspec >= 0.8 && < 0.9+ , hspec >= 1.3 , file-location >= 0.4 && < 0.5 , base >= 4 && < 5- , QuickCheck == 2.4.*+ , QuickCheck , path-pieces , text source-repository head type: git- location: git://github.com/snoyberg/path-pieces.git+ location: https://github.com/yesodweb/path-pieces
+ test/main.hs view
@@ -0,0 +1,69 @@+{-# Language ScopedTypeVariables #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Main where++import Test.Hspec+import Test.Hspec.QuickCheck(prop)+import Test.QuickCheck++import Web.PathPieces+import qualified Data.Text as T+import Data.Maybe (fromJust)++-- import FileLocation (debug)++instance Arbitrary T.Text where+ arbitrary = fmap T.pack arbitrary+++main :: IO ()+main = hspec spec++spec :: Spec+spec = do+ describe "PathPiece" $ do+ prop "toPathPiece <=> fromPathPiece String" $ \(p::String) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> null p+ Just pConverted -> p == pConverted++ prop "toPathPiece <=> fromPathPiece String" $ \(p::T.Text) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> T.null p+ Just pConverted -> p == pConverted++ prop "toPathPiece <=> fromPathPiece String" $ \(p::Int) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> p < 0+ Just pConverted -> p == pConverted++ describe "PathMultiPiece" $ do+ prop "toPathMultiPiece <=> fromPathMultiPiece String" $ \(p::[String]) ->+ p == (fromJust . fromPathMultiPiece . toPathMultiPiece) p++ prop "toPathMultiPiece <=> fromPathMultiPiece String" $ \(p::[T.Text]) ->+ p == (fromJust . fromPathMultiPiece . toPathMultiPiece) p+++ describe "SinglePiece" $ do+ prop "toPathPiece <=> fromPathPiece String" $ \(p::String) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> null p+ Just pConverted -> p == pConverted++ prop "toPathPiece <=> fromPathPiece String" $ \(p::T.Text) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> T.null p+ Just pConverted -> p == pConverted++ prop "toPathPiece <=> fromPathPiece String" $ \(p::Int) ->+ case (fromPathPiece . toPathPiece) p of+ Nothing -> p < 0+ Just pConverted -> p == pConverted++ describe "MultiPiece" $ do+ prop "toPathMultiPiece <=> fromPathMultiPiece String" $ \(p::[String]) ->+ p == (fromJust . fromPathMultiPiece . toPathMultiPiece) p++ prop "toPathMultiPiece <=> fromPathMultiPiece String" $ \(p::[T.Text]) ->+ p == (fromJust . fromPathMultiPiece . toPathMultiPiece) p