From 91a0614cc49b41d32b2102076b5d8d746d4f0221 Mon Sep 17 00:00:00 2001 From: Javran Cheng Date: Mon, 29 Aug 2022 19:56:40 -0700 Subject: [PATCH 1/2] Fix test for aeson-2+ aeson-2 switched to use KeyMap interface instead of HashMap. Some inpiration from https://github.com/haskell/aeson/issues/881 Fix https://github.com/monadfix/shower/issues/17 --- tests/Property.hs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/Property.hs b/tests/Property.hs index eb455e0..852fc6e 100644 --- a/tests/Property.hs +++ b/tests/Property.hs @@ -1,10 +1,10 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} module Property where import qualified Data.Text as Text import qualified Data.Vector as Vector -import qualified Data.HashMap.Strict as HashMap import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy.UTF8 as UTF8 @@ -12,18 +12,32 @@ import Test.QuickCheck import Test.Tasty import Test.Tasty.QuickCheck +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.Key as Key +import qualified Data.Aeson.KeyMap as KeyMap +#else +import qualified Data.HashMap.Strict as HashMap +#endif + import Shower -- | 'Aeson.Value' generator, stolen from @api-tools@. genJSON :: Gen Aeson.Value genJSON = sized $ \size -> oneof [ - Aeson.Object . HashMap.fromList <$> - resize (size `div` 2) (listOf ((,) <$> (Text.pack <$> arbitrary) <*> genJSON)), + Aeson.Object . objectFromList <$> + resize (size `div` 2) (listOf ((,) <$> (keyFromText . Text.pack <$> arbitrary) <*> genJSON)), Aeson.Array . Vector.fromList <$> resize (size `div` 2) (listOf genJSON), Aeson.String . Text.pack <$> arbitrary, Aeson.Number . fromInteger <$> arbitrary, Aeson.Bool <$> arbitrary, pure Aeson.Null ] + where + (objectFromList, keyFromText) = +#if MIN_VERSION_aeson(2,0,0) + (KeyMap.fromList, Key.fromText) +#else + (HashMap.fromList, id) +#endif -- | Test that formatting always works on JSON and never changes it. prop_JSON :: Property From 4d74639fe1380129b8540ca7058ee46ef61b1075 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Thu, 22 Sep 2022 15:40:40 -0400 Subject: [PATCH 2/2] Bump base upper bounds. --- shower.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shower.cabal b/shower.cabal index f3597d8..a66e023 100644 --- a/shower.cabal +++ b/shower.cabal @@ -28,7 +28,7 @@ library Shower.Parser Shower.Class build-depends: - base >=4.10 && <4.16, + base >=4.10 && <4.18, megaparsec, pretty hs-source-dirs: lib @@ -38,7 +38,7 @@ library executable shower main-is: Main.hs build-depends: - base >=4.10 && <4.16, + base >=4.10 && <4.18, shower hs-source-dirs: exe default-language: Haskell2010 @@ -50,7 +50,7 @@ test-suite shower-tests Property type: exitcode-stdio-1.0 build-depends: - base >=4.10 && <4.16, + base >=4.10 && <4.18, aeson, tasty, tasty-golden,