@@ -25,6 +25,7 @@ import qualified Data.Text.Lazy.Builder as B
2525import Data.Time
2626import Data.Time.Clock.POSIX
2727import Language.Haskell.TH
28+import Lens.Micro (ASetter, (&), (.~))
2829import System.Posix.Types
2930import Test.QuickCheck.Instances ()
3031import Test.Tasty
@@ -41,6 +42,7 @@ tests = testGroup "Katip"
4142 [
4243 testProperty "JSON cycle Item" $ \(i :: Item ()) ->
4344 prop_json_cycle i
45+ , eqItemTests
4446 , testProperty "renderSeverity/textToSeverity cycle" $ \sev ->
4547 textToSeverity(renderSeverity sev) === Just sev
4648 , testProperty "processIDToText/textToProcessID cycle" $ \pid ->
@@ -245,11 +247,6 @@ deriving instance Arbitrary Namespace
245247deriving instance Arbitrary Environment
246248deriving instance Arbitrary ThreadIdText
247249deriving instance Arbitrary CPid
248−#if !MIN_VERSION_base(4, 8, 0)
249−deriving instance Eq Loc
250−#endif
251−deriving instance Eq LogStr
252−deriving instance (Eq a) => Eq (Item a)
253250
254251
255252-------------------------------------------------------------------------------
@@ -278,3 +275,31 @@ instance Arbitrary Severity where
278275-------------------------------------------------------------------------------
279276instance Arbitrary LogStr where
280277 arbitrary = LogStr . B.fromText <$> arbitrary
278+
279+-------------------------------------------------------------------------------
280+-- Somewhat test whether all fields are taken into account in `==`
281+
282+#if !MIN_VERSION_template_haskell(2, 10, 0)
283+-- `testProperty` requires these instances
284+deriving instance Eq Loc
285+deriving instance Show Loc
286+#endif
287+
288+eqItemTests :: TestTree
289+eqItemTests = testGroup "Eq Item"
290+ [ testProperty "itemApp" $ prop_field itemApp
291+ , testProperty "itemEnv" $ prop_field itemEnv
292+ , testProperty "itemSeverity" $ prop_field itemSeverity
293+ , testProperty "itemThread" $ prop_field itemThread
294+ , testProperty "itemHost" $ prop_field itemHost
295+ , testProperty "itemProcess" $ prop_field itemProcess
296+ , testProperty "itemPayload" $ prop_field itemPayload
297+ , testProperty "itemMessage" $ prop_field itemMessage
298+ , testProperty "itemTime" $ prop_field itemTime
299+ , testProperty "itemNamespace" $ prop_field itemNamespace
300+ , testProperty "itemLoc" $ prop_field itemLoc
301+ ]
302+ where
303+ prop_field :: Eq a => ASetter (Item ()) (Item ()) a a -> Item () -> a -> a -> Bool
304+ prop_field field item f1 f2 =
305+ ((item & field .~ f1) == (item & field .~ f2)) == (f1 == f2)