diff options
author | Joey Hess <joeyh@joeyh.name> | 2019-01-21 13:40:11 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2019-01-21 13:50:24 -0400 |
commit | f76c4a09739e150c01d8d6565d0b9c33c340b37f (patch) | |
tree | 18e2caf2ad6fccb0d79845b53c34faeffcb60263 /Types | |
parent | e15d18058b7326e61823db4c6d38c20bef691c92 (diff) |
avoid Arbitrary generating excessivly long lists
Turns what it was doing often generated too long lists, or spun with
suchThat rejecting too large numbers. Limit lists to 10.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/MetaData.hs | 5 | ||||
-rw-r--r-- | Types/View.hs | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/Types/MetaData.hs b/Types/MetaData.hs index bc7c3eea3e..fce941c576 100644 --- a/Types/MetaData.hs +++ b/Types/MetaData.hs @@ -337,9 +337,8 @@ fromRemoteMetaData (RemoteMetaData u (MetaData m)) = MetaData $ - the seriaization test slow due to the sheer amount of data. - It's unlikely that more than 100 fields of metadata will be used. -} instance Arbitrary MetaData where - arbitrary = do - size <- arbitrarySizedBoundedIntegral `suchThat` (< 500) - MetaData . M.filterWithKey legal . M.fromList <$> vector size + arbitrary = MetaData . M.filterWithKey legal . M.fromList + <$> resize 10 (listOf arbitrary) where legal k _v = legalField $ fromMetaField k diff --git a/Types/View.hs b/Types/View.hs index a6c52b3d28..f18647371d 100644 --- a/Types/View.hs +++ b/Types/View.hs @@ -23,7 +23,8 @@ data View = View deriving (Eq, Read, Show) instance Arbitrary View where - arbitrary = View <$> pure (Git.Ref "master") <*> arbitrary + arbitrary = View (Git.Ref "master") + <$> resize 10 (listOf arbitrary) data ViewComponent = ViewComponent { viewField :: MetaField @@ -43,8 +44,7 @@ data ViewFilter instance Arbitrary ViewFilter where arbitrary = do - size <- arbitrarySizedBoundedIntegral `suchThat` (< 100) - s <- S.fromList <$> vector size + s <- S.fromList <$> resize 10 (listOf arbitrary) ifM arbitrary ( return (FilterValues s) , return (ExcludeValues s) |