diff --git a/test/SplitSpec.hs b/test/SplitSpec.hs index 8482cb5f8..5cba2a075 100644 --- a/test/SplitSpec.hs +++ b/test/SplitSpec.hs @@ -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)