mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Add an Arbitrary instance over Patch.
This commit is contained in:
parent
ea16b4616c
commit
f8443c855c
@ -11,6 +11,7 @@ import Data.String
|
||||
import Data.Text.Arbitrary ()
|
||||
import Data.These
|
||||
import Diff
|
||||
import Patch
|
||||
import Prologue
|
||||
import Syntax
|
||||
import Term
|
||||
@ -73,3 +74,9 @@ instance (Arbitrary leaf, Arbitrary annotation) => Arbitrary (ArbitraryDiff leaf
|
||||
(1, Fixed . take maxLength <$> listOf (smallerTerm maxLength maxDepth)),
|
||||
(1, Keyed . Map.fromList . take maxLength <$> listOf (arbitrary >>= (\x -> (,) x <$> smallerTerm maxLength maxDepth))) ]
|
||||
smallerTerm maxLength maxDepth = boundedTerm (div maxLength 3) (div maxDepth 3)
|
||||
instance Arbitrary a => Arbitrary (Patch a) where
|
||||
arbitrary = oneof [
|
||||
Insert <$> arbitrary,
|
||||
Delete <$> arbitrary,
|
||||
Replace <$> arbitrary <*> arbitrary ]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user