1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Generate arbitrary Fixed terms with bounds &c.

This commit is contained in:
Rob Rix 2015-12-11 14:40:29 -05:00
parent c4326d54a0
commit 2e97bf44fc

View File

@ -37,7 +37,8 @@ instance (Eq a, Eq annotation, Arbitrary a, Arbitrary annotation) => Arbitrary (
boundedSyntax 0 = liftM Leaf arbitrary
boundedSyntax n = frequency
[ (1, liftM Leaf arbitrary),
(4, liftM Indexed . listOf . boundedTerm $ n - 1) ]
(4, liftM Indexed . listOf . boundedTerm $ n - 1),
(4, liftM Fixed . listOf . boundedTerm $ n - 1) ]
shrink term@(ArbitraryTerm (annotation, syntax)) = (++) (subterms term) $ filter (/= term) $ ArbitraryTerm <$> ((,) <$> shrink annotation <*> shrinkSyntax syntax)
where shrinkSyntax (Leaf a) = Leaf <$> shrink a
shrinkSyntax (Indexed i) = Indexed <$> (List.subsequences i >>= recursivelyShrink)