mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Use Break to represent newlines.
This commit is contained in:
parent
5b8908ac82
commit
0c9308b6ae
33
test/Spec.hs
33
test/Spec.hs
@ -37,8 +37,8 @@ main = hspec $ do
|
||||
([
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "[ ", span "a", Text "," ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Text "[ ", span "a", Text "," ] ]),
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "", span "b", Text " ]" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Text "", span "b", Text " ]" ] ])
|
||||
Row (Line [ Ul (Just "category-branch") [ Break, span "b", Text " ]" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Break, span "b", Text " ]" ] ])
|
||||
], (Range 0 8, Range 0 8))
|
||||
|
||||
it "outputs two rows for two-line non-empty formatted indexed nodes" $
|
||||
@ -50,9 +50,9 @@ main = hspec $ do
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "[ ", span "a", Text "," ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Text "[" ] ]),
|
||||
Row EmptyLine
|
||||
(Line [ Ul (Just "category-branch") [ Text "", span "a", Text "," ] ]),
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "", span "b", Text " ]" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Text "", span "b", Text " ]" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Break, span "a", Text "," ] ]),
|
||||
Row (Line [ Ul (Just "category-branch") [ Break, span "b", Text " ]" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Break, span "b", Text " ]" ] ])
|
||||
], (Range 0 8, Range 0 8))
|
||||
|
||||
it "" $
|
||||
@ -64,11 +64,11 @@ main = hspec $ do
|
||||
([
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "[" ] ])
|
||||
(Line [ Ul (Just "category-branch") [ Text "[", span "a", Text ",", span "b", Text "]" ] ]),
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "", span "a" ] ])
|
||||
Row (Line [ Ul (Just "category-branch") [ Break, span "a" ] ])
|
||||
EmptyLine,
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "", Text "," ] ])
|
||||
Row (Line [ Ul (Just "category-branch") [ Break, Text "," ] ])
|
||||
EmptyLine,
|
||||
Row (Line [ Ul (Just "category-branch") [ Text "", span "b", Text "]" ] ])
|
||||
Row (Line [ Ul (Just "category-branch") [ Break, span "b", Text "]" ] ])
|
||||
EmptyLine
|
||||
], (Range 0 8, Range 0 5))
|
||||
|
||||
@ -77,20 +77,20 @@ main = hspec $ do
|
||||
adjoin2 [ rightRowText "[" ] (rightRowText "a") `shouldBe` [ rightRow [ Text "[", Text "a" ] ]
|
||||
|
||||
it "appends onto newlines" $
|
||||
adjoin2 [ leftRow [ newline ] ] (leftRowText ",") `shouldBe`
|
||||
[ leftRow [ newline, Text "," ] ]
|
||||
adjoin2 [ leftRow [ Break ] ] (leftRowText ",") `shouldBe`
|
||||
[ leftRow [ Break, Text "," ] ]
|
||||
|
||||
it "produces new rows for newlines" $
|
||||
adjoin2 [ leftRowText "a" ] (leftRow [ newline ]) `shouldBe`
|
||||
[ leftRow [ newline ], leftRowText "a" ]
|
||||
adjoin2 [ leftRowText "a" ] (leftRow [ Break ]) `shouldBe`
|
||||
[ leftRow [ Break ], leftRowText "a" ]
|
||||
|
||||
it "promotes HTML through empty lines" $
|
||||
adjoin2 [ rightRowText "b", leftRow [ newline ] ] (leftRowText "a") `shouldBe`
|
||||
[ rightRowText "b", leftRow [ newline, Text "a" ] ]
|
||||
adjoin2 [ rightRowText "b", leftRow [ Break ] ] (leftRowText "a") `shouldBe`
|
||||
[ rightRowText "b", leftRow [ Break, Text "a" ] ]
|
||||
|
||||
it "does not promote newlines through empty lines" $
|
||||
adjoin2 [ rightRowText "c", rowText "a" "b" ] (leftRow [ newline ]) `shouldBe`
|
||||
[ leftRow [ newline ], rightRowText "c", rowText "a" "b" ]
|
||||
adjoin2 [ rightRowText "c", rowText "a" "b" ] (leftRow [ Break ]) `shouldBe`
|
||||
[ leftRow [ Break ], rightRowText "c", rowText "a" "b" ]
|
||||
|
||||
where
|
||||
rightRowText text = rightRow [ Text text ]
|
||||
@ -98,7 +98,6 @@ main = hspec $ do
|
||||
leftRowText text = leftRow [ Text text ]
|
||||
leftRow xs = Row (Line xs) EmptyLine
|
||||
rowText a b = Row (Line [ Text a ]) (Line [ Text b ])
|
||||
newline = Text ""
|
||||
info source category = Info (totalRange source) (Range 0 0) (Set.fromList [ category ])
|
||||
unchanged source category = formatted source source category
|
||||
formatted source1 source2 category = Annotated (info source1 category, info source2 category)
|
||||
|
Loading…
Reference in New Issue
Block a user