mirror of
https://github.com/github/semantic.git
synced 2024-11-24 00:42:33 +03:00
Move the Arbitrary instance for Patch into semantic-diff proper.
This commit is contained in:
parent
a613fa0369
commit
378b577175
@ -13,6 +13,7 @@ import Data.Text.Arbitrary ()
|
||||
import Data.These
|
||||
import Diff
|
||||
import Patch
|
||||
import Patch.Arbitrary ()
|
||||
import Prologue
|
||||
import Syntax
|
||||
import Term.Arbitrary
|
||||
@ -79,11 +80,3 @@ instance (Eq leaf, Eq annotation, Arbitrary leaf, Arbitrary annotation) => Arbit
|
||||
Fixed f -> Fixed <$> (List.subsequences f >>= recursivelyShrink)
|
||||
Keyed k -> Keyed . Map.fromList <$> (List.subsequences (Map.toList k) >>= recursivelyShrink)
|
||||
Pure patch -> ArbitraryDiff . Pure <$> shrink patch
|
||||
|
||||
instance Arbitrary a => Arbitrary (Patch a) where
|
||||
arbitrary = oneof [
|
||||
Insert <$> arbitrary,
|
||||
Delete <$> arbitrary,
|
||||
Replace <$> arbitrary <*> arbitrary ]
|
||||
|
||||
shrink patch = traverse shrink patch
|
||||
|
@ -27,6 +27,7 @@ library
|
||||
, Operation
|
||||
, Parser
|
||||
, Patch
|
||||
, Patch.Arbitrary
|
||||
, Range
|
||||
, Renderer
|
||||
, Renderer.JSON
|
||||
|
14
src/Patch/Arbitrary.hs
Normal file
14
src/Patch/Arbitrary.hs
Normal file
@ -0,0 +1,14 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
module Patch.Arbitrary where
|
||||
|
||||
import Patch
|
||||
import Prologue
|
||||
import Test.QuickCheck
|
||||
|
||||
instance Arbitrary a => Arbitrary (Patch a) where
|
||||
arbitrary = oneof [
|
||||
Insert <$> arbitrary,
|
||||
Delete <$> arbitrary,
|
||||
Replace <$> arbitrary <*> arbitrary ]
|
||||
|
||||
shrink patch = traverse shrink patch
|
@ -7,7 +7,6 @@ import Data.Functor.Both
|
||||
import Data.Text.Arbitrary ()
|
||||
import Data.These
|
||||
import Info
|
||||
import Patch
|
||||
import Prologue hiding (fst, snd)
|
||||
import Range
|
||||
import Source hiding ((++))
|
||||
@ -33,12 +32,6 @@ instance Arbitrary a => Arbitrary (Join These a) where
|
||||
arbitrary = Join <$> arbitrary
|
||||
shrink (Join a) = Join <$> shrink a
|
||||
|
||||
instance Arbitrary a => Arbitrary (Patch a) where
|
||||
arbitrary = oneof [
|
||||
Insert <$> arbitrary,
|
||||
Delete <$> arbitrary,
|
||||
Replace <$> arbitrary <*> arbitrary ]
|
||||
|
||||
instance Arbitrary a => Arbitrary (Source a) where
|
||||
arbitrary = Source.fromList <$> arbitrary
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user