hpack 0.5.3 → 0.5.4
raw patch · 3 files changed
+29/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hpack.cabal +2/−2
- src/Hpack/Util.hs +3/−1
- test/Hpack/UtilSpec.hs +24/−5
hpack.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.5.2.+-- This file has been generated from package.yaml by hpack version 0.5.3. -- -- see: https://github.com/sol/hpack name: hpack-version: 0.5.3+version: 0.5.4 synopsis: An alternative format for Haskell packages homepage: https://github.com/sol/hpack#readme bug-reports: https://github.com/sol/hpack/issues
src/Hpack/Util.hs view
@@ -42,7 +42,9 @@ deriving (Eq, Show, Data, Typeable) instance FromJSON a => FromJSON (List a) where- parseJSON v = List <$> (parseJSON v <|> (return <$> parseJSON v))+ parseJSON v = List <$> case v of+ Array _ -> parseJSON v+ _ -> return <$> parseJSON v type GhcOption = String
test/Hpack/UtilSpec.hs view
@@ -1,10 +1,14 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-} module Hpack.UtilSpec (main, spec) where -import Helper import Data.Aeson+import Data.Aeson.QQ+import Data.Aeson.Types+import Helper import System.Directory +import Hpack.Config import Hpack.Util main :: IO ()@@ -53,11 +57,26 @@ ] describe "List" $ do- it "can be a single value" $ do- fromJSON (toJSON $ Number 23) `shouldBe` Success (List [23 :: Int])+ let invalid = [aesonQQ|{+ name: "hpack",+ gi: "sol/hpack",+ ref: "master"+ }|]+ parseError :: Either String (List Dependency)+ parseError = Left "neither key \"git\" nor key \"github\" present"+ context "when parsing single values" $ do+ it "returns the value in a singleton list" $ do+ fromJSON (toJSON $ Number 23) `shouldBe` Success (List [23 :: Int]) - it "can be a list of values" $ do- fromJSON (toJSON [Number 23, Number 42]) `shouldBe` Success (List [23, 42 :: Int])+ it "returns error messages from element parsing" $ do+ parseEither parseJSON invalid `shouldBe` parseError++ context "when parsing a list of values" $ do+ it "returns the list" $ do+ fromJSON (toJSON [Number 23, Number 42]) `shouldBe` Success (List [23, 42 :: Int])++ it "propagates parse error messages of invalid elements" $ do+ parseEither parseJSON (toJSON [String "foo", invalid]) `shouldBe` parseError describe "tryReadFile" $ do it "reads file" $ do