@@ -17,6 +17,7 @@ import Test.Hspec.QuickCheck(prop)
1717import Test.QuickCheck
1818
1919import Web.HttpApiData
20+import Web.HttpApiData.Internal
2021
2122instance Arbitrary T.Text where
2223 arbitrary = T.pack <$> arbitrary
@@ -63,13 +64,13 @@ instance ToHttpApiData a => ToHttpApiData (RandomCase a) where
6364instance FromHttpApiData a => FromHttpApiData (RandomCase a) where
6465 parseUrlPiece s = RandomCase [] <$> parseUrlPiece s
6566
66−-- | Check case insensitivity for @fromUrlPiece@.
67+-- | Check case insensitivity for @parseUrlPiece@.
6768checkUrlPieceI :: forall a. (Eq a, ToHttpApiData a, FromHttpApiData a, Show a, Arbitrary a) => Proxy a -> String -> Spec
6869checkUrlPieceI _ = checkUrlPiece (Proxy :: Proxy (RandomCase a))
6970
7071spec :: Spec
7172spec = do
72− describe "toUrlPiece <=> fromUrlPiece" $ do
73+ describe "toUrlPiece <=> parseUrlPiece" $ do
7374 checkUrlPiece (Proxy :: Proxy ()) "()"
7475 checkUrlPiece (Proxy :: Proxy Char) "Char"
7576 checkUrlPieceI (Proxy :: Proxy Bool) "Bool"
@@ -97,12 +98,9 @@ spec = do
9798 checkUrlPieceI (Proxy :: Proxy (Either Version Day)) "Either Version Day"
9899
99100 it "bad integers are rejected" $ do
100− fromUrlPiece (T.pack "123hello") `shouldBe` (Nothing :: Maybe Int)
101+ parseUrlPieceMaybe (T.pack "123hello") `shouldBe` (Nothing :: Maybe Int)
101102
102103 it "bounds checking works" $ do
103− fromUrlPiece (T.pack "256") `shouldBe` (Nothing :: Maybe Int8)
104− fromUrlPiece (T.pack "-10") `shouldBe` (Nothing :: Maybe Word)
105− where
106− fromUrlPiece :: FromHttpApiData a => T.Text -> Maybe a
107− fromUrlPiece = either (const Nothing) Just . parseUrlPiece
104+ parseUrlPieceMaybe (T.pack "256") `shouldBe` (Nothing :: Maybe Int8)
105+ parseUrlPieceMaybe (T.pack "-10") `shouldBe` (Nothing :: Maybe Word)
108106