From 4b928a6c4ed8bbbce06ad59b316f5df8e6894b95 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 30 Nov 2017 10:41:26 -0500 Subject: [PATCH] Test that derived & generic showsPrec agree. --- test/Data/Functor/Classes/Generic/Spec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Data/Functor/Classes/Generic/Spec.hs b/test/Data/Functor/Classes/Generic/Spec.hs index 44c3c273c..1b4017634 100644 --- a/test/Data/Functor/Classes/Generic/Spec.hs +++ b/test/Data/Functor/Classes/Generic/Spec.hs @@ -30,6 +30,17 @@ spec = parallel $ do prop "equivalent to derived compare for recursive types" $ \ a b -> genericLiftCompare compare a b `shouldBe` compare a (b :: Tree Int) + describe "Show1" $ do + describe "genericLiftShowsPrec" $ do + prop "equivalent to derived showsPrec for product types" $ + \ a -> genericLiftShowsPrec showsPrec showList 0 a "" `shouldBe` showsPrec 0 (a :: Product Int) "" + + prop "equivalent to derived showsPrec for sum types" $ + \ a -> genericLiftShowsPrec showsPrec showList 0 a "" `shouldBe` showsPrec 0 (a :: Sum Int) "" + + prop "equivalent to derived showsPrec for recursive types" $ + \ a -> genericLiftShowsPrec showsPrec showList 0 a "" `shouldBe` showsPrec 0 (a :: Tree Int) "" + data Product a = Product a a a deriving (Eq, Generic1, Ord, Show) @@ -53,3 +64,4 @@ instance Listable a => Listable (Tree a) where instance Eq1 Tree where liftEq = genericLiftEq instance Ord1 Tree where liftCompare = genericLiftCompare +instance Show1 Tree where liftShowsPrec = genericLiftShowsPrec