mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Add replacement summaries
This commit is contained in:
parent
ab3b8faf32
commit
aade9415aa
@ -63,7 +63,9 @@ instance Show a => Show (DiffSummary a) where
|
||||
++ if null parentAnnotations then "" else " to the " ++ intercalate "#" (termName <$> parentAnnotations) ++ " context"
|
||||
(Delete termInfo) -> "Deleted the " ++ "'" ++ fromJust (term termInfo) ++ "' " ++ termName termInfo
|
||||
++ if null parentAnnotations then "" else " in the " ++ intercalate "#" (termName <$> parentAnnotations) ++ " context"
|
||||
(Replace t1 t2) -> "Replaced "
|
||||
(Replace t1 t2) -> "Replaced the " ++ "'" ++ fromJust (term t1) ++ "' " ++ termName t1
|
||||
++ " with the " ++ "'" ++ fromJust (term t2) ++ "' " ++ termName t2
|
||||
++ if null parentAnnotations then "" else " in the " ++ intercalate "#" (termName <$> parentAnnotations) ++ " context"
|
||||
|
||||
diffSummary :: IsTerm leaf => Diff leaf Info -> [DiffSummary DiffInfo]
|
||||
diffSummary = cata diffSummary' where
|
||||
|
@ -24,6 +24,9 @@ testDiff = free $ Free (pure arrayInfo :< Indexed [ free $ Pure (Insert (cofree
|
||||
testSummary :: DiffSummary Char
|
||||
testSummary = DiffSummary { patch = Insert (DiffInfo "string literal" (Just "a")), parentAnnotations = [] }
|
||||
|
||||
replacementSummary :: DiffSummary Char
|
||||
replacementSummary = DiffSummary { patch = Replace (DiffInfo "string literal" (Just "a")) (DiffInfo "symbol literal" (Just "b")), parentAnnotations = [ (DiffInfo "array literal" Nothing)] }
|
||||
|
||||
spec :: Spec
|
||||
spec = parallel $ do
|
||||
describe "diffSummary" $ do
|
||||
@ -32,3 +35,5 @@ spec = parallel $ do
|
||||
describe "show" $ do
|
||||
it "should print adds" $
|
||||
show testSummary `shouldBe` "Added the 'a' string literal"
|
||||
it "prints a replacement" $ do
|
||||
show replacementSummary `shouldBe` "Replaced the 'a' string literal with the 'b' symbol literal in the array literal context"
|
||||
|
Loading…
Reference in New Issue
Block a user