mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Shrink subsequences of Indexed terms.
This commit is contained in:
parent
8d0272bdac
commit
dacb2dba48
@ -8,6 +8,7 @@ import Syntax
|
||||
import Term
|
||||
import Control.Comonad.Cofree
|
||||
import Control.Monad.Free hiding (unfold)
|
||||
import qualified Data.List as List
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
import Data.Tuple
|
||||
@ -26,7 +27,7 @@ instance (Arbitrary a, Arbitrary annotation) => Arbitrary (ArbitraryTerm a annot
|
||||
arbitrary = arbitraryBounded 4
|
||||
shrink (ArbitraryTerm (annotation, syntax)) = ArbitraryTerm <$> ((,) <$> shrink annotation <*> shrinkSyntax syntax)
|
||||
where shrinkSyntax (Leaf a) = Leaf <$> shrink a
|
||||
shrinkSyntax (Indexed i) = (getSyntax <$> i) ++ (Indexed <$> shrink i)
|
||||
shrinkSyntax (Indexed i) = (getSyntax <$> i) ++ (Indexed <$> List.subsequences i) ++ (Indexed <$> shrink i)
|
||||
shrinkSyntax (Syntax.Fixed f) = (getSyntax <$> 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