Verified Commit 8b561379 authored by Camil Staps's avatar Camil Staps 🚀

Don't generate duplicate properties for properties that use less type variables

parent ef4b096b
......@@ -362,15 +362,23 @@ generateProperties :: ![PropertyVarInstantiation] ![NamedTestGenerator] !String
generateProperties pvis generators fname doc =
[gen i fname doc.preconditions p config
\\ p <- doc.properties
, config <- configurations $ groupInstantiations $ pvis ++ docPropertyTestWith doc
, config <- configurationsForProperty p (pvis ++ docPropertyTestWith doc)
& i <- [1..]]
where
groupInstantiations :: [PropertyVarInstantiation] -> [[(String,Type)]]
groupInstantiations pvis = groupBy ((==) `on` fst) $ sortBy ((<) `on` fst) [vi \\ PropertyVarInstantiation vi <- pvis]
configurationsForProperty :: !Property ![PropertyVarInstantiation] -> [[(String,Type)]]
configurationsForProperty (ForAll _ ts _) pvis =
case [vi \\ PropertyVarInstantiation vi=:(v,_) <- pvis | isMember v allvs] of
[] -> [[]]
vis -> configurations $ groupInstantiations vis
where
allvs = concatMap (allVars o snd) ts
groupInstantiations :: [(String,Type)] -> [[(String,Type)]]
groupInstantiations pvis = groupBy ((==) `on` fst) $ sortBy ((<) `on` fst) pvis
configurations :: [[(String,Type)]] -> [[(String,Type)]]
configurations [vis:viss] = [[vi`:vis`] \\ vi` <- vis, vis` <- configurations viss]
configurations [] = [[]]
configurations :: [[(String,Type)]] -> [[(String,Type)]]
configurations [vis:viss] = [[vi`:vis`] \\ vi` <- vis, vis` <- configurations viss]
configurations [] = [[]]
gen :: !Int !String ![String] !Property ![(String,Type)] -> GeneratedProperty
gen i fname preconditions (ForAll name ts imp) vis =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment