mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Test that we preserve the line counts in equal diffs.
This commit is contained in:
parent
9e6f415dc6
commit
ef027dba36
@ -46,6 +46,10 @@ spec = do
|
||||
\ source -> splitAnnotatedByLines (source, source) (totalRange source, totalRange source) (mempty, mempty) (Indexed [] :: Syntax String (Diff String Info)) `shouldBe` [
|
||||
Row (Line [ Free $ Annotated (Info (totalRange source) mempty) $ Indexed [] ]) (Line [ Free $ Annotated (Info (totalRange source) mempty) $ Indexed [] ]) ]
|
||||
|
||||
prop "preserves line counts in equal sources" $
|
||||
\ source -> let range = totalRange source in
|
||||
length (splitAnnotatedByLines (source, source) (totalRange source, totalRange source) (mempty, mempty) (Indexed . fst $ foldl combineIntoLeaves ([], 0) source)) `shouldBe` length (filter (== '\n') source) + 1
|
||||
|
||||
describe "annotatedToRows" $ do
|
||||
it "outputs one row for single-line empty unchanged indexed nodes" $
|
||||
annotatedToRows (unchanged "[]" "branch" (Indexed [])) "[]" "[]" `shouldBe` [ Row (Line [ Ul (Just "category-branch") [ Text "[]" ] ]) (Line [ Ul (Just "category-branch") [ Text "[]" ] ]) ]
|
||||
@ -213,3 +217,5 @@ spec = do
|
||||
isClosed (Row _ _) = False
|
||||
|
||||
isOnSingleLine (a, _, _) = filter (/= '\n') a == a
|
||||
|
||||
combineIntoLeaves (leaves, start) char = (leaves ++ [ Free $ Annotated (Info (Range start $ start + 1) mempty, Info (Range start $ start + 1) mempty) (Leaf [ char ]) ], start + 1)
|
||||
|
Loading…
Reference in New Issue
Block a user