mirror of
https://github.com/github/semantic.git
synced 2024-12-20 21:31:48 +03:00
Generate arbitrarily-sized terms.
This commit is contained in:
parent
5b5add0c2d
commit
1e049c7dcb
@ -35,7 +35,9 @@ termOfSize n = (ArbitraryTerm .) . (:<) <$> arbitrary <*> syntaxOfSize n
|
||||
-- Instances
|
||||
|
||||
instance (Eq leaf, Eq annotation, Arbitrary leaf, Arbitrary annotation) => Arbitrary (ArbitraryTerm leaf annotation) where
|
||||
arbitrary = sized termOfSize
|
||||
arbitrary = sized $ \ n -> do
|
||||
m <- choose (0, n)
|
||||
termOfSize m
|
||||
|
||||
shrink term@(ArbitraryTerm (annotation :< syntax)) = (subterms term ++) $ filter (/= term) $
|
||||
(ArbitraryTerm .) . (:<) <$> shrink annotation <*> case syntax of
|
||||
|
Loading…
Reference in New Issue
Block a user