mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Use the correct functions in the diffs.
This commit is contained in:
parent
919f166f7a
commit
4c87a91f19
@ -22,14 +22,14 @@ spec = parallel $ do
|
||||
|
||||
prop "equal terms produce identity diffs" $
|
||||
\ a -> let term = decorate (a :: Term Syntax (Record '[Category])) in
|
||||
diffCost (diffTerms term term) `shouldBe` 0
|
||||
diffCost (diffSyntaxTerms term term) `shouldBe` 0
|
||||
|
||||
describe "beforeTerm" $ do
|
||||
prop "recovers the before term" $
|
||||
\ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
\ a b -> let diff = diffSyntaxTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
beforeTerm diff `shouldBe` Just a
|
||||
|
||||
describe "afterTerm" $ do
|
||||
prop "recovers the after term" $
|
||||
\ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
\ a b -> let diff = diffSyntaxTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
afterTerm diff `shouldBe` Just b
|
||||
|
@ -20,17 +20,17 @@ spec = parallel $ do
|
||||
it "returns a replacement when comparing two unicode equivalent terms" $
|
||||
let termA = Term $ (StringLiteral :. Nil) `In` Leaf "t\776"
|
||||
termB = Term $ (StringLiteral :. Nil) `In` Leaf "\7831" in
|
||||
diffTerms termA termB `shouldBe` replacing termA termB
|
||||
diffSyntaxTerms termA termB `shouldBe` replacing termA termB
|
||||
|
||||
prop "produces correct diffs" $
|
||||
\ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
\ a b -> let diff = diffSyntaxTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
(beforeTerm diff, afterTerm diff) `shouldBe` (Just a, Just b)
|
||||
|
||||
prop "constructs zero-cost diffs of equal terms" $
|
||||
\ a -> let diff = diffTerms a a :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
\ a -> let diff = diffSyntaxTerms a a :: Diff Syntax (Record '[Category]) (Record '[Category]) in
|
||||
diffCost diff `shouldBe` 0
|
||||
|
||||
it "produces unbiased insertions within branches" $
|
||||
let term s = Term ((StringLiteral :. Nil) `In` Indexed [ Term ((StringLiteral :. Nil) `In` Leaf s) ]) :: Term Syntax (Record '[Category])
|
||||
root = termIn (Program :. Nil) . Indexed in
|
||||
diffTerms (root [ term "b" ]) (root [ term "a", term "b" ]) `shouldBe` merge ((Program :. Nil, Program :. Nil)) (Indexed [ inserting (term "a"), cata (\ (In a r) -> merge (a, a) r) (term "b") ])
|
||||
diffSyntaxTerms (root [ term "b" ]) (root [ term "a", term "b" ]) `shouldBe` merge ((Program :. Nil, Program :. Nil)) (Indexed [ inserting (term "a"), cata (\ (In a r) -> merge (a, a) r) (term "b") ])
|
||||
|
@ -48,7 +48,7 @@ spec = parallel $ do
|
||||
\ diff -> let diff' = (diff :: Diff Syntax () ()) in entryPayload <$> tableOfContentsBy (const (Just ())) diff' `shouldBe` replicate (diffSize diff') ()
|
||||
|
||||
prop "produces an unchanged entry for identity diffs" $
|
||||
\ term -> tableOfContentsBy (Just . termAnnotation) (diffTerms term term) `shouldBe` [Unchanged (lastValue (term :: Term Syntax (Record '[Category])))]
|
||||
\ term -> tableOfContentsBy (Just . termAnnotation) (diffSyntaxTerms term term) `shouldBe` [Unchanged (lastValue (term :: Term Syntax (Record '[Category])))]
|
||||
|
||||
prop "produces inserted/deleted/replaced entries for relevant nodes within patches" $
|
||||
\ p -> tableOfContentsBy (Just . termAnnotation) (patch deleting inserting replacing p)
|
||||
@ -135,7 +135,7 @@ spec = parallel $ do
|
||||
|
||||
prop "equal terms produce identity diffs" $
|
||||
\a -> let term = defaultFeatureVectorDecorator (Info.category . termAnnotation) (a :: Term') in
|
||||
diffTOC (diffTerms term term) `shouldBe` []
|
||||
diffTOC (diffSyntaxTerms term term) `shouldBe` []
|
||||
|
||||
describe "JSONSummary" $ do
|
||||
it "encodes modified summaries to JSON" $ do
|
||||
|
Loading…
Reference in New Issue
Block a user