1
1
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:
Rob Rix 2015-12-22 15:48:37 -05:00
parent 9e6f415dc6
commit ef027dba36

View File

@ -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)