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:
parent
c4326d54a0
commit
2e97bf44fc
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user