mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Shrink subterms recursively.
This commit is contained in:
parent
65bd8b19c8
commit
d5041aaf5e
@ -27,7 +27,7 @@ instance (Eq a, Eq annotation, Arbitrary a, Arbitrary annotation) => Arbitrary (
|
||||
arbitrary = arbitraryBounded 4
|
||||
shrink term@(ArbitraryTerm (annotation, syntax)) = filter (/= term) $ ArbitraryTerm <$> ((,) <$> shrink annotation <*> shrinkSyntax syntax)
|
||||
where shrinkSyntax (Leaf a) = Leaf <$> shrink a
|
||||
shrinkSyntax (Indexed i) = (getSyntax <$> i) ++ (Indexed <$> List.subsequences i)
|
||||
shrinkSyntax (Indexed i) = (getSyntax <$> i) ++ (Indexed <$> (shrink =<< List.subsequences i))
|
||||
shrinkSyntax (Syntax.Fixed f) = (getSyntax <$> f) ++ (Syntax.Fixed <$> List.subsequences f) ++ (Syntax.Fixed <$> shrink f)
|
||||
shrinkSyntax (Keyed k) = (getSyntax . snd <$> (Map.toList k)) ++ (Keyed . Map.fromList <$> shrink (Map.toList k))
|
||||
getSyntax (ArbitraryTerm (_, syntax)) = syntax
|
||||
|
Loading…
Reference in New Issue
Block a user