fix metadata log simplifier and additional quickcheck tests
This commit is contained in:
parent
4d205b0fb9
commit
a05ac13e92
3 changed files with 9 additions and 6 deletions
|
@ -119,7 +119,7 @@ addMetaData k metadata = do
|
|||
-
|
||||
- So, the only simplication that is actually done is to throw out an
|
||||
- old line when all the values in it have been overridden by lines that
|
||||
- came before
|
||||
- came after.
|
||||
-}
|
||||
simplifyLog :: Log MetaData -> Log MetaData
|
||||
simplifyLog s = case S.toDescList s of
|
||||
|
@ -128,7 +128,7 @@ simplifyLog s = case S.toDescList s of
|
|||
where
|
||||
go c _ [] = c
|
||||
go c newer (l:ls)
|
||||
| older `hasUniqueMetaData` newer =
|
||||
| hasUniqueMetaData newer older =
|
||||
go (l:c) (unionMetaData older newer) ls
|
||||
| otherwise = go c newer ls
|
||||
where
|
||||
|
|
2
Test.hs
2
Test.hs
|
@ -145,7 +145,7 @@ properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck"
|
|||
, testProperty "prop_hashes_stable" Utility.Hash.prop_hashes_stable
|
||||
, testProperty "prop_schedule_roundtrips" Utility.Scheduled.prop_schedule_roundtrips
|
||||
, testProperty "prop_duration_roundtrips" Utility.HumanTime.prop_duration_roundtrips
|
||||
, testProperty "prop_updateMetaData_sane" Types.MetaData.prop_updateMetaData_sane
|
||||
, testProperty "prop_metadata_sane" Types.MetaData.prop_metadata_sane
|
||||
, testProperty "prop_metadata_serialize" Types.MetaData.prop_metadata_serialize
|
||||
]
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module Types.MetaData (
|
|||
getAllMetaData,
|
||||
serialize,
|
||||
deserialize,
|
||||
prop_updateMetaData_sane,
|
||||
prop_metadata_sane,
|
||||
prop_metadata_serialize
|
||||
) where
|
||||
|
||||
|
@ -199,10 +199,13 @@ instance Arbitrary MetaValue where
|
|||
instance Arbitrary MetaField where
|
||||
arbitrary = MetaField <$> arbitrary `suchThat` legalField
|
||||
|
||||
prop_updateMetaData_sane :: MetaData -> MetaField -> MetaValue -> Bool
|
||||
prop_updateMetaData_sane m f v = and
|
||||
prop_metadata_sane :: MetaData -> MetaField -> MetaValue -> Bool
|
||||
prop_metadata_sane m f v = and
|
||||
[ S.member v $ getAllMetaData f m'
|
||||
, not (isSet v) || S.member v (currentMetaDataValues f m')
|
||||
, not (hasUniqueMetaData m m)
|
||||
, hasUniqueMetaData newMetaData m'
|
||||
, not (hasUniqueMetaData m' newMetaData)
|
||||
]
|
||||
where
|
||||
m' = updateMetaData f v m
|
||||
|
|
Loading…
Reference in a new issue