1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Add an Arbitrary instance over These.

This commit is contained in:
Rob Rix 2016-04-26 14:14:31 -04:00
parent 64026caa06
commit b64a67128c

View File

@ -11,6 +11,7 @@ import qualified Data.OrderedMap as Map
import qualified Data.List as List
import qualified Data.Set as Set
import Data.Text.Arbitrary ()
import Data.These
import Info
import Patch
import Prelude hiding (fst, snd)
@ -60,6 +61,11 @@ instance Arbitrary a => Arbitrary (Join (,) a) where
arbitrary = both <$> arbitrary <*> arbitrary
shrink b = both <$> shrink (fst b) <*> shrink (snd b)
instance (Arbitrary a, Arbitrary b) => Arbitrary (These a b) where
arbitrary = oneof [ This <$> arbitrary
, That <$> arbitrary
, These <$> arbitrary <*> arbitrary ]
instance Arbitrary a => Arbitrary (Patch a) where
arbitrary = oneof [
Insert <$> arbitrary,