add missing test file

This commit is contained in:
Willem Van Onsem 2021-06-10 22:55:31 +02:00
parent 000f901a93
commit e83882c35b
No known key found for this signature in database
GPG Key ID: 1D22C3A122D794F4

28
test/VerifyAttributes.hs Normal file
View File

@ -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
]