From e83882c35b630c8412de34add5c9ac38f6e2266b Mon Sep 17 00:00:00 2001 From: Willem Van Onsem Date: Thu, 10 Jun 2021 22:55:31 +0200 Subject: [PATCH] add missing test file --- test/VerifyAttributes.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/VerifyAttributes.hs diff --git a/test/VerifyAttributes.hs b/test/VerifyAttributes.hs new file mode 100644 index 0000000..45f343b --- /dev/null +++ b/test/VerifyAttributes.hs @@ -0,0 +1,28 @@ +module VerifyAttributes where + +import Verify + +import Graphics.Vty.Attributes(MaybeDefault(Default, KeepCurrent, SetTo)) + +instance Arbitrary a => Arbitrary (MaybeDefault a) where + arbitrary = oneof [pure Default, pure KeepCurrent, SetTo <$> arbitrary] + +oldSem :: MaybeDefault a -> MaybeDefault a -> MaybeDefault a +oldSem Default Default = Default +oldSem Default KeepCurrent = Default +oldSem Default (SetTo v) = SetTo v +oldSem KeepCurrent Default = Default +oldSem KeepCurrent KeepCurrent = KeepCurrent +oldSem KeepCurrent (SetTo v) = SetTo v +oldSem (SetTo _v) Default = Default +oldSem (SetTo v) KeepCurrent = SetTo v +oldSem (SetTo _) (SetTo v) = SetTo v + +sameSemigroupValue :: MaybeDefault Int -> MaybeDefault Int -> Bool +sameSemigroupValue xa xb = xa <> xb == oldSem xa xb + +tests :: IO [Test] +tests = return + [ verify "check that the new Semigroup of MaybeDefault is equivalent to the old one" sameSemigroupValue + ] +